mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Added ability to attach metadata to uploads
no-issue Currently the onUploadSuccess and onUploadFailure have no way to identify which upload has succeeded or failed other than the filename. However the filename is not guaranteed to be unqiue, so this can cause bugs.
This commit is contained in:
parent
f788cd6dfa
commit
1b9854b99f
1 changed files with 4 additions and 3 deletions
|
@ -244,9 +244,10 @@ export default Component.extend({
|
|||
let ajax = this.ajax;
|
||||
let formData = this._getFormData(file);
|
||||
let url = `${ghostPaths().apiRoot}${this.uploadUrl}`;
|
||||
let metadata = null;
|
||||
|
||||
try {
|
||||
this.onUploadStart(file);
|
||||
metadata = yield Promise.resolve(this.onUploadStart(file));
|
||||
|
||||
let response = yield ajax[this.requestMethod](url, {
|
||||
data: formData,
|
||||
|
@ -296,7 +297,7 @@ export default Component.extend({
|
|||
};
|
||||
|
||||
this.uploadUrls[index] = result;
|
||||
this.onUploadSuccess(result);
|
||||
this.onUploadSuccess(result, metadata);
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
|
@ -317,7 +318,7 @@ export default Component.extend({
|
|||
|
||||
// TODO: check for or expose known error types?
|
||||
this.errors.pushObject(result);
|
||||
this.onUploadFailure(result);
|
||||
this.onUploadFailure(result, metadata);
|
||||
}
|
||||
}).maxConcurrency(MAX_SIMULTANEOUS_UPLOADS).enqueue(),
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue