fortana-co / react-dropzone-uploader

React file dropzone and uploader
https://react-dropzone-uploader.js.org/
MIT License
447 stars 183 forks source link

"ready" status is not possible when uploading files without `getUploadParams` #55

Open aussio opened 4 years ago

aussio commented 4 years ago

If the below description of a bug is me just misusing the react-dropzone-uploader API, please let me know. 😄

I'm looking to upload files using the firebase API which does not appear to readily provide a URL to POST/PUT objects into. From following the examples and reading your documentation, this led me to believe that I should look for the ready status within the onChangeStatus callback and upload accordingly.

The documentation reads the following for the ready and done statuses respectively:

'ready'

  • only set if you pass autoUpload={false}; set when file has been prepared and validated; client code can call fileWithMeta.restart to start upload

'done'

  • set for successful upload when xhr.readyState is DONE; response body is available
  • if you don't pass a getUploadParams function because you're not using RDU to upload files, this is set after file is prepared and validated

This leads me to believe that I should look out for the ready status since I'm looking to upload the files manually and that the done status should only trigger when a file is finished being uploaded.

I believe if autoUpload={false} and no getUploadParams is provided, the status should be ready and not done. If this is correct, the bug/misassumption of the API looks to be able to be found here: https://github.com/fortana-co/react-dropzone-uploader/blob/89aa88acf753962398fee967d0e4b5ac5d53065a/src/Dropzone.tsx#L427-L436

hochan222 commented 4 years ago

autoUpload After giving the false option, Here is the function that goes in onChangeStatus.

 const handleChangeStatus = ({ meta, file }, status) => {
    console.log(status, meta, file);
    if (status === 'ready') {
      meta.status = 'headers_received';
      // dispatch({ label: 'ADD FILES', data: file });
    }
  };

One of the results.

getting_upload_params {name: "favicon.ico", size: 4638, type: "image/vnd.microsoft.icon", lastModifiedDate: "2020-03-12T00:31:28.839Z", uploadedDate: "2020-05-25T06:48:12.089Z", …} File {name: "favicon.ico", lastModified: 1583973088839, lastModifiedDate: Thu Mar 12 2020 09:31:28 GMT+0900 (Korean Standard Time), webkitRelativePath: "", size: 4638, …}

Check it out with the above function. I see the right life cycle.

dancixx commented 4 years ago

If the below description of a bug is me just misusing the react-dropzone-uploader API, please let me know. 😄

I'm looking to upload files using the firebase API which does not appear to readily provide a URL to POST/PUT objects into. From following the examples and reading your documentation, this led me to believe that I should look for the ready status within the onChangeStatus callback and upload accordingly.

The documentation reads the following for the ready and done statuses respectively:

'ready'

  • only set if you pass autoUpload={false}; set when file has been prepared and validated; client code can call fileWithMeta.restart to start upload

'done'

  • set for successful upload when xhr.readyState is DONE; response body is available
  • if you don't pass a getUploadParams function because you're not using RDU to upload files, this is set after file is prepared and validated

This leads me to believe that I should look out for the ready status since I'm looking to upload the files manually and that the done status should only trigger when a file is finished being uploaded.

I believe if autoUpload={false} and no getUploadParams is provided, the status should be ready and not done. If this is correct, the bug/misassumption of the API looks to be able to be found here:

https://github.com/fortana-co/react-dropzone-uploader/blob/89aa88acf753962398fee967d0e4b5ac5d53065a/src/Dropzone.tsx#L427-L436

Can you solve the firebase upload problem?