Cannot reupload same file (single file upload)
Paskalouis opened 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 :
- User browse file into upload field
- User fills other fields.
- User Submit
- Upload is done by .upload
- After upload done, call another API, this API returns error that belongs to 'other fields'
- User fix 'other fields'
- User Submit again
- 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 :
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~