pattern-library icon indicating copy to clipboard operation
pattern-library copied to clipboard

axa-file-upload: fix logic to determine if uploaded file was an image

Open baumkaenguru opened this issue 2 years ago • 2 comments

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

  1. Open Codesandbox
  2. Try to drag and drop a random csv file into the file-upload component
  3. ????
  4. Profit

Context (Environment)

Possible Solution

fix this line

baumkaenguru avatar Aug 15 '22 15:08 baumkaenguru

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.

MKaHead avatar Aug 18 '22 15:08 MKaHead

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.

baumkaenguru avatar Aug 18 '22 20:08 baumkaenguru

awesome, thank you!

baumkaenguru avatar Sep 09 '22 14:09 baumkaenguru

@baumkaenguru release will come on Monday 12. September. I should close next time after release.

MKaHead avatar Sep 09 '22 14:09 MKaHead