ImagePicker file name and mime-type

How can i get name and mime-type using ImagePicker? In url i creates a copy of file with hash-name, but i need original name

The API doesn’t currently return the image name, the name would not generally be useful because it is auto generated by the system (unless loaded by user onto an Android phone). Can you describe the case where returning the original name would be useful? We may consider adding it into a future release.

The mime-type can be inferred from the extension on the uri returned in the result, but is not returned in the result.

I’m going to do image upload on server, so on site you can see image preview and it’s name a the bottom of it. I have found document picker with the type image/*, it returns right name, but I’m still unable to upload it because it’s uri starts with protocol content://

In general there is no well-defined name from the OS for an image that the user picks. You could have the user enter a name manually and just use that. Images are mostly just blobs of color data, with some metadata such as exif stuff (orientation, information about the camera, or such), but when a person takes a photo and saves it on the phone, what would be a nice name for it?

I agree that camera photos will have generated name, but not hash. Like IMG_201709010852

How would this be more useful than 'IMG_' + Math.random(4000)?

1 Like

On Android the file names from the Camera use a timestamp file format e.g. 20200331_122110.jpg and when a photo was taken can in some cases be relevant information that we want to pass on to an app.

Specific use case: I am coding a small app that lets the user pick and resize a photo and then save the photo back to local storage. This app is one step in a larger workflow where the user later uploads the resized image to Airtable. The step is needed to avoid uploading very large files. Neither Airtable nor Google Photos have a (free) build in action to reduce image size. It is important that the original filename is carried over since later steps will use filename comparisons to check which images in Android Photos have already been uploaded to Airtable.

This use case is currently blocked because ImagePicker creates a new, random (?) filename and does not pass along the original filename.

I think the above is a good reason for making the original filename available to ImagePicker.

Indeed, why not make ImagePicker default to simply reuse the original filename (with a unique random suffix in the rare cases when needed to avoid naming conflicts in cache)? Because the current default seems to destroy information for no benefit.


Currently I need to save the original name of my file captured by the camera on my backend, is it not possible then?