knownasilya/ember-plupload

Cannot reupload same file (single file upload)

Closed this issue · 4 comments

Hello,
Thanks for this nice library ! Been using this since 1-2 years ago, but I stumbled upon perhaps bug, or wrong handling.

I have a case like this :

  1. User browse file into upload field
  2. User fills other fields.
  3. User Submit
  4. Upload is done by .upload
  5. After upload done, call another API, this API returns error that belongs to 'other fields'
  6. User fix 'other fields'
  7. User Submit again
  8. The file that already uploaded, cannot uploaded again, so I can't proceed to .then hook. The process stucked.

I have using .splice and .refresh function to refresh uploader according to this https://stackoverflow.com/questions/4720928/refresh-plupload

I put this on error for next API call after upload complete :

controller.get('merchant_documents_1').get('uploader').splice();
controller.get('merchant_documents_1').get('uploader').refresh();

Is this a bug or wrong handling ?

Actually this can be handled by removing the file again, so user need to upload file again. But that would be inefficient if there are lot of single upload fields.

Thank you

Ahh. The file has already been uploaded, so the file is completed. You'd probably need to hold on to the promise result of the file upload in your retry. Does that make sense?

Hello,
Thanks for the reply.

Do you mean there is another hook for second retry where the file is completed ?
I have checked my server log, on first try, where file haven't uploaded, the POST is called :
image

On second try, where the file is already uploaded, when calling .upload again, there is no log POST here. So it just stuck there. The promise is not resolved, so I cannot execute code inside .then(func(){})

Here is my upload piece of code :

controller.get('merchant_documents_1').upload('/api/v1/merchants/document', {
       data: {some properties here}
}).then(function(response) {
     // After upload here, technically here I am AJAX to other API that may result error, so user will submit again then go to this merchant_documents_1 upload again
});

Thank you.

Hi Evans.

I am now using your new https://github.com/tim-evans/ember-file-upload
And using this, it shows the ember error where it tells the file already uploaded.
I think this one is better.

Thank you

Thanks~