uploadthing icon indicating copy to clipboard operation
uploadthing copied to clipboard

feat: More restrictive MIME types for better UX uploading images from Android

Open oBusk opened this issue 8 months ago โ€ข 3 comments

Describe the feature you'd like to request

The UploadButton component creates a <input type="file"> which includes every image/* MIME in it's accept="", apparently because some OSes don't want to use image/*. Some of these mime types, causes Android to opt out of their "Cloud media app" flow, and instead of showing all images from your google Photos, to select a file instead.

File Selector Cloud media
Screenshot_20240602-131834 Screenshot_20240602-131851

I tested a small thing https://image-mime-types.vercel.app/ and it seems like all MIME types with a period in them, triggers the file selection flow intead of the cloud media flow. Which honestly sounds like a bug in Android, but you know.

I was thinking how to work around this? Do I create add one config entry for each MIME I want to support? I also tried having the key in my FileRouter to be all mime types comma separated, which builds and creates a Upload button that's correct, but API gets sad when I upload.

I also was considering writing my own component so that I can specify a more restrictive "accepts" while using the "image" file route config.

But either way, I feel like the "out of the box" experience of uploadthing should be as smooth as possible? If you create upload of images, it shoul go into the image gallery path rather than "find a file on your phone".

Describe the solution you'd like to see

I think "UploadButton" component could recieve configuration to allow us to modify the accepts, but I also think that the default when using image in your File route, should exlcude all image types with periods in them. But if UploadThing don't want to build a work-around for an android/chrome bug(?) I also think that's fair.

Additional information

I've been trying to find information about what rules trigger the "Cloud media app" on android, but I honestly can't find any.. It's a case of unfortunate mix of buzz words...

๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Contributing

  • [X] ๐Ÿ™‹โ€โ™‚๏ธ Yes, I'd be down to file a PR implementing this feature!

oBusk avatar Jun 02 '24 11:06 oBusk