Hi Team,
Is it possible to append uploadFiles at the bottom after form data when sending REST API to upload files to API?
As per current order,
* Upload files
* Path
* action
* save
expected order
* path
* action
* save
* upload files
As i want to retrieve form fields first from request body to create directory at the server before storing the file. Kindly advise if it is possible
onCreated() {
(Uploader as any).prototype.uploadFilesRequest = function(selectedFiles, i, custom) {
var _this = this;
var cloneFiles = [];
var chunkEnabled = this.checkChunkUpload();
var ajax = new Ajax(this.asyncSettings.saveUrl, 'POST', true, null);
ajax.emitError = false;
var getFileData;
if (this.isServerBlazor) {
getFileData = selectedFiles.slice(0);
cloneFiles.push(getFileData[i].rawFile);
}
var eventArgs = {
fileData: this.isServerBlazor ? getFileData[i] : selectedFiles[i],
customFormData: [],
cancel: false,
currentRequest: null
};
var formData = new FormData();
ajax.beforeSend = function(e) {
……
if (eventArgs.cancel) {
_this.eventCancelByArgs(e, eventArgs, selectedFiles[i]);
}
//Custom Form Data
var customFormDatas = [
{ path: eventArgs.customFormData[0].path },
{ action: eventArgs.customFormData[1].action },
{ data: eventArgs.customFormData[2].data }
];
eventArgs.customFormData = customFormDatas;
//Update Form Data
_this.updateFormData(formData, eventArgs.customFormData);
});
var name_5 = this.element.getAttribute('name');
formData.append(
name_5,
selectedFiles[i].rawFile,
selectedFiles[i].name
);
……
ajax.send(formData);
}
}
};
} |
|
Highly appreciated it. it works perfectly for my requirement. thanks a lot.