benwinding / react-admin-firebase

A firebase data provider for the react-admin framework
https://benwinding.github.io/react-admin-firebase/
MIT License
460 stars 174 forks source link

Uploading file to Firebase Storage replaces file filename with 'file' or index number #132

Open benfoley opened 4 years ago

benfoley commented 4 years ago

I was expecting that FileInput uploads would use the file names when saving them into the Firebase Storage bucket, but the file is renamed. Is there an option to keep the original filename?

My upload code is:

<FileInput source="file" label="File" accept="" multiple={true}>
  <FileField source="src" title="title" />
</FileInput>

Uploading two files results in this data in the Firestore record:

file:
0
src: "https://firebasestorage.googleapis.com/v0/b/BUCKET/o/entries%2Fentry%2Ffile%2F0?alt=media&token=TOKEN"
title: "test.pdf"
1
src: "https://firebasestorage.googleapis.com/v0/b/BUCKET/o/entries%2Fentry%2Ffile%2F1?alt=media&token=TOKEN"
title: "test-2.pdf"

And Storage ends up with two PDFs with files named 0 and 1. If multiple is false, then the file is renamed to file.

Can it be set to save the files with original names? Thanks

benwinding commented 4 years ago

Hey @benfoley, Thanks for contributing, that's a great idea. I'll merge in your PR and add it as an option to the configuration options. Cheers, Ben