React-admin: file upload not working

Created on 27 Jul 2019  路  8Comments  路  Source: marmelab/react-admin

What you were expecting:
The file would show in the file upload box after dragging or selecting it.

What happened instead:
Nothing is shown after the file is dragged or selected

Steps to reproduce:
create a simple tabbed form with a file upload component in it

Related code:

<FormTab label="Files">
<ImageInput source="mainImage" label="Main Image" accept="image/*">
    <ImageField source="mainImage" />
</ImageInput>
<ImageInput source="images" label="Images" multiple accept="image/*">
    <ImageField source="images" />
</ImageInput>

<FileInput
    source="game"
    label="Game File"
    accept="application/zip"
    placeholder={<p>Drop your file here</p>}>
    <FileField source="gameZip" />
    <br />
</FileInput>
<br />
<FileInput source="gif" label="Gif" accept="application/gif">
    <FileField source="gif" />
</FileInput>
</FormTab>

Environment

  • React-admin version: 2.9.4
  • Last version that did not exhibit the issue (if applicable): ...
  • React version: 16.8.6
  • Browser: Google Chrome Version 75.0.3770.142
needs more info

Most helpful comment

I added a simple fileinput component after the imageinput in postedit.js.
it works with pdf and images but not with zip files.

https://codesandbox.io/s/simple-6rxkf?fontsize=14&module=%2Fsrc%2Fposts%2FPostEdit.js

@mahdinba97 Your example works and accept zip on my Mac, but not on Windows.

I've experienced same issue before, and finally debugged, that Windows often incorrectly identify mime types and use application/octet-stream. So, right now I've removed accept property and checking file type on server.

All 8 comments

Did you add the upload decorator like this?
https://marmelab.com/react-admin/DataProviders.html#decorating-your-data-provider-example-of-file-upload

Did you add the upload decorator like this?
https://marmelab.com/react-admin/DataProviders.html#decorating-your-data-provider-example-of-file-upload

I think decorator is not related to fileinput. I've built the form-data upload feature in my custom data provider and i have the same issue but ImageInput works properly.

Thank you for opening this issue. In order to confirm it, we'll have to reproduce it.
As explained in the bug report template, please fork the following CodeSandbox and repeat your issue on it:

https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple

This is the simplest way to confirm a bug is related to the React Admin codebase.

I added a simple fileinput component after the imageinput in postedit.js.
it works with pdf and images but not with zip files.

https://codesandbox.io/s/simple-6rxkf?fontsize=14&module=%2Fsrc%2Fposts%2FPostEdit.js

In my project which React Admin v2.9.4 is installed, FileInput accepts nothing.

I added a simple fileinput component after the imageinput in postedit.js.
it works with pdf and images but not with zip files.

https://codesandbox.io/s/simple-6rxkf?fontsize=14&module=%2Fsrc%2Fposts%2FPostEdit.js

@mahdinba97 Your example works and accept zip on my Mac, but not on Windows.

I've experienced same issue before, and finally debugged, that Windows often incorrectly identify mime types and use application/octet-stream. So, right now I've removed accept property and checking file type on server.

Is this fixed? @djhi

There is no issue in react-admin here. Open a new one if you think there is

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicgirault picture nicgirault  路  3Comments

pixelscripter picture pixelscripter  路  3Comments

ericwb picture ericwb  路  3Comments

Kmaschta picture Kmaschta  路  3Comments

kdabir picture kdabir  路  3Comments