fris-fruitig / react-firebase-file-uploader

An image uploader for react that uploads images to your firebase storage
https://npm.im/react-firebase-file-uploader
166 stars 45 forks source link

remove file extension #20

Closed temitope closed 6 years ago

temitope commented 6 years ago

I am trying to save a file with no file extension.

i.e. filename.jpeg being saved to filename_uid

however it seems that whether i use a function or just a generated string it automatically appends the default extension to what I am returning. Is this an option I am missing? Are you open to PRs?

temitope commented 6 years ago

@sprmn I see it is here in the src/index.js line 58 or so // Ensure there is an extension in the filename if (!extractExtension(filenameToUse)) { filenameToUse += extractExtension(file.name); }

perhaps we can add a check for another prop. maybe something like allowExtensionlessFilename ?

sprmn commented 6 years ago

Hi @temitope, thanks for opening an issue and feel free to add this prop and submit a PR. It shouldn't be much work.

However, could you provide some more info about your use case? Why do you need a file without extension?

temitope commented 6 years ago

@sprmn yeah, simple enough.

So for my app we were storing the urls based on userids and wanted a uniform url, so instead of processing gifs, pngs and jpegs to a single format and keeping the extension, we just leave it off and let the browser interpret the image. This allowed us to generate/know the image urls without querying the database. As I was in a bit of a rush I made some tweaks on my send so I can manage without it for now since we dont actually do this anymore, but I thought it would be nice to have. I will close this for now.