Reputation: 27791
this.uploader.on('onAllComplete', (succeeded, failed) => {
const successfulUploadResponses = succeeded.map(o => this.uploader.methods.something(o)));
// do something w/successfulUploadResponses
});
I need to fill in the something
above. Can I access the response for each uploaded file?
Upvotes: 0
Views: 111
Reputation: 38962
The onComplete
callback is called when an item completes uploading.
It is passed id
, name
, responseJSON
and xhr
for the uploaded item.
The responseJSON
for completed uploads can be stored in an object using file id as key.
In the onAllComplete
callback, responseJSON
can be retrieved using the file id in the array of successful uploads.
const RESPONSE_JSON = {};
this.uploader.on('onComplete', (id, name, responseJSON, xhr) => {
RESPONSE_JSON[id] = responseJSON;
})
this.uploader.on('onAllComplete', (succeeded, failed) => {
const successfulUploadResponses = succeeded.map(id => RESPONSE_JSON[id]);
// do something w/successfulUploadResponses
});
Upvotes: 1