GithubHelp home page GithubHelp logo

Comments (11)

dbarrosop avatar dbarrosop commented on May 26, 2024

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.

Svarto avatar Svarto commented on May 26, 2024

@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.

dbarrosop avatar dbarrosop commented on May 26, 2024

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.

dbarrosop avatar dbarrosop commented on May 26, 2024

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.

Svarto avatar Svarto commented on May 26, 2024

@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.

dbarrosop avatar dbarrosop commented on May 26, 2024

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:

Screenshot 2022-07-05 at 15 43 24

from hasura-storage.

dbarrosop avatar dbarrosop commented on May 26, 2024

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.

Svarto avatar Svarto commented on May 26, 2024

@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.

dbarrosop avatar dbarrosop commented on May 26, 2024

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.

Svarto avatar Svarto commented on May 26, 2024

@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.

dbarrosop avatar dbarrosop commented on May 26, 2024

no worries, glad the issue was sorted out :)

from hasura-storage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.