This commit is contained in:
@@ -392,6 +392,47 @@ export default {
|
||||
handleError("DUPLICATE", error, route, reject);
|
||||
});
|
||||
});
|
||||
},
|
||||
///////////////////////////////////
|
||||
// POST FILE ATTACHMENTS
|
||||
// @param {ayId:objectid, ayType:objectType, files:[array of files]}
|
||||
//
|
||||
uploadAttachment(at) {
|
||||
let that = this;
|
||||
|
||||
var files = at.files;
|
||||
var data = new FormData();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
data.append(files[i].name, files[i]);
|
||||
}
|
||||
|
||||
data.append("AttachToObjectType", at.ayaType);
|
||||
data.append("AttachToObjectId", at.ayaId);
|
||||
|
||||
//-----------------
|
||||
|
||||
return new Promise(function postAttachmentToServer(resolve, reject) {
|
||||
let fetchOptions = {
|
||||
method: "post",
|
||||
mode: "cors",
|
||||
headers: {
|
||||
Authorization: "Bearer " + window.$gz.store.state.apiToken
|
||||
},
|
||||
body: data
|
||||
};
|
||||
|
||||
fetch(that.APIUrl("Attachment"), fetchOptions)
|
||||
.then(that.status)
|
||||
.then(that.json)
|
||||
// eslint-disable-next-line
|
||||
.then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch(function handlePostAttachment(error) {
|
||||
handleError("POSTATTACHMENT", error, route, reject);
|
||||
});
|
||||
});
|
||||
//---------------
|
||||
}
|
||||
|
||||
//new functions above here
|
||||
|
||||
Reference in New Issue
Block a user