pattern-library
pattern-library copied to clipboard
axa-file-upload: fix logic to determine if uploaded file was an image
File-upload molecule cannot handle (non image/* and non application/*) files properly. e.g. text/csv
Expected Behavior
If I upload a file which is not an image and doesn't contain 'application' in its MIME-Type e.g. "text/csv", I'd like to see the usual paperclip icon in the list of added files. Also, I'd expect the readme to match the change logs description that all filetypes are now allowed (since 5.1.0)
Current Behavior
Currently the component thinks it has to handle an image since the check for non-image-files looks something like this:
const isNonImageFile = file.type.indexOf('application') > -1;
Therefore it wants to create a preview, which obviously doesn't work.
Steps to Reproduce
- Open Codesandbox
- Try to drag and drop a random csv file into the file-upload component
- ????
- Profit
Context (Environment)
Possible Solution
fix this line
Hi @baumkaenguru, thanks for creating the issue. I'm a little surprised that all file types would be allowed. As I remembered that it should not be possible for security reasons. However, that also depends on the context of where your app is running, I'll look into that. Otherwise nothing in the way to fix it.
Hi @MKaHead: Thats at least what it said in the changelog for version 5.1.0:
Allow all file types
- Added an allowedFileTypes attribute.
- Now, every file type can be uploaded.
awesome, thank you!
@baumkaenguru release will come on Monday 12. September. I should close next time after release.