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

File size limit #16

Open ghost opened 6 years ago

ghost commented 6 years ago

Could we add file size limit api to this library? Thanks for the awesome work here.

sprmn commented 6 years ago

Hi @proverbface, thanks for your thanks and your suggestion.

We can certainly add that functionality. I started a new branch for adding some preprocessors or other functions before starting the upload a while ago (See also https://github.com/fris-fruitig/react-firebase-file-uploader/issues/11#issuecomment-344598190). I think we could add a check for file size in a similar way like this:

const MAX_SIZE = 1e6; // in bytes
...
<FileUploader
  beforeUploadStart={file => { if (file.size > MAX_FILE_SIZE) throw Error('File too large') }}
  ...
/>

Would this work for you or would you prefer a maxSize prop? Other suggestions are welcome as well.

ghost commented 6 years ago

Thanks for your quick reply. I think both ways would make sense. The maxSize prop sounds even nicer.

shotap commented 6 years ago

any updates on this issue?

Neta-Alon commented 5 years ago

Would also love to see this implemented :)

thepors commented 3 years ago

@sprmn Hi, I added beforeUploadStart into<CustomUploadButton /> and I got a warning

Warning: React does not recognize the beforeUploadStart prop on a DOM element

Any suggestion please?