When adding an image file from a device that is retrieved by the user to firebase cloud storage, would it be okay to append .jpg, .png, or .webp to the filename?

For example,

storageReference.child('images/example.jpg').putFile(file)

or

storageReference.child('images/example.png').putFile(file)

I've been doing this in the past with no problems, but it doesn't feel right. Would I have to retrieve the file type and add the appropriate extension?

I would want all the images in the firebase storage to have the same file extension, but I am not sure if getting different file types from ImagePicker and adding a uniform extension is a proper way to save an image?

Creating a flutter app...


Solution 1: eandpi

You don't need to specify a type. If you specify a specific file ending like .png or .jpg, firebase storage will override the auto-detected type. Take a look at the firebase storage docs here. It goes into more depth, but bottom-line answer is if you specify a file type firebase storage will update the initial auto-detected type.