Comments (11)
png
and jpg
images are supported, the issue is that you are sending an invalid mime type (which v1 didn't check). Please, send a valid mime type and it should work just fine.
For more info you can refer to the following url: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
from hasura-storage.
@dbarrosop thank you for the response!
I am not sending any mime type, I am just navigating to an URL that serves an image stored in my Nhost storage. If I understand you correctly, it means that Nhost storage does not validate the mime type of the images OR just passes on incorrect mime types to the transformation function in the storage.
Can you please help how to manage this when migrating from v1, how can I correct the mime types of the images I have on v2 storage?
from hasura-storage.
Would you mind sharing an image that isn't working so I can test myself? Feel free to share here (if they can be shared) or ping me on discord if you prefer to do it privately.
from hasura-storage.
Also, would you mind giving more details on how those images where uploaded? Did you do it yourself with code? (would you mind sharing?) or via the storage UI?
from hasura-storage.
@dbarrosop of course, here is an image: https://rklttyqwdzlikrmxlvpg.storage.eu-central-1.nhost.run/v1/files/13dca9dd-ea3d-48d8-9d63-a80f635191a3
I think that the issue we are running into here is that on mobile when picking an image from the camera roll or taking an image, the mime type is not provided. So it has to be generated, I am generating it by taking the type (which returns image or photo, depending on OS / phone) and then the ending of the file (which can be jpg, jpeg or png depending on OS and phone). These generated mime types create some that are aligning to official standards, and others that are not.
code:
type: `${image.type}/${image.uri.substring(
image.uri.lastIndexOf(".") + 1
)}`
I can standardize it in my frontend (there are some good mime JS libraries that read the mime type from the file name), with that said it won't fix my 1000+ images that are already uploaded to nhost in v1...
from hasura-storage.
By default the storage service will figure out the mime type and set it correctly so unless you have some specific need to compute it yourself I'd recommend just letting the service do it itself. I tried to upload your picture using our files UI (which doesn't bother with the MIME type) and it worked as expected:
from hasura-storage.
Also, not sure if you are writing to the database yourself, but there is no need for it (and actually I would discourage you from doing it), you can just upload the file and everything should be filled for you. Reading is fine though.
from hasura-storage.
@dbarrosop is it possible that this changed since 16th March? When I upload a mislabeled image now (i.e. content-type image/jpg) it gets automatically stored in storage with a correct mime-type image/jpeg?
I will need to remigrate all my images, but that can be done with minor modifications of my previous migrate script.
from hasura-storage.
don't recall the exact date (I could check) but we release around April a rewritten version of hasura-storage. Previous version handled mimetypes when uploading this way too though.
The announcement was here: https://nhost.io/blog/hasura-storage-in-go-5x-performance-increase-and-40-percent-less-ram
from hasura-storage.
@dbarrosop this seems to be a none issue now, as when I run my migration script and re-upload images they are automatically identified as the correct mimetype even when taken "as-is" from nhost v1. Thanks a lot for the help!
from hasura-storage.
no worries, glad the issue was sorted out :)
from hasura-storage.
Related Issues (20)
- Manual migrations HOT 7
- How to handle secret injection HOT 9
- Support max_upload_file_size > 50mb default HOT 10
- How to upload file using <input type=file />? HOT 1
- Add X-Hasura-Role in CORS headers HOT 1
- Storage.files table should have a metadata column (like auth.users) HOT 5
- Storage.buckets table should be enum HOT 4
- Image transformation (quality) does not seem to work properly HOT 4
- Allow admin role to create pre-signed URLs with arbitrary expirations HOT 2
- Documentation for using hasura-storage outside of nhost
- Compatibility with Hasura graphql-default naming convention HOT 1
- openapi docs: /presignedurl, not /presigned HOT 1
- Generate multiple presigned urls from a single request HOT 2
- investigate potential memory leak with image manipulation HOT 1
- Upgrading to v0.4.0 causes application panic HOT 3
- Forwarding Content-Length and Content-Type breaks upload flow HOT 1
- Migartions database name should be configurable HOT 2
- v0.5.0 - s3-endpoint breaking change HOT 3
- Image orientation metadata lost when transformations applied HOT 3
- Service unable to restart after crashing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hasura-storage.