on 11-09-2016 10:08 PM
I am currently writing an SAPUI5 app that will be used to create service tickets using oData onto C4C.
The user has a form to create the service tickets. This form also has an option to upload multiple files and also multiple items with products.
For creating the items I am using oData batch processing
I am able to upload a single file using something like below:
However, I am having a difficult time to come up with the approach on how I can handle the multiple files. In case of single file, the actual oData call is currently happening on fileReader.onload
How can I accomplish for using multiple files ??
Any suggestions are highly appreciated.
uploadPictures: function(result) {
if (this.picturesFileToUpload) {
var fileReader = new FileReader();
fileReader.onload = function(e) {
this.uploadFile(e, result);
}.bind(this);
fileReader.readAsBinaryString(this.picturesFileToUpload);
}
},
uploadFile: function(e, result) {
var model = this.getModel(),
url = result.getElementsByTagName("id")[0].innerHTML + "/ServiceRequestAttachmentFolder",
token = model.getSecurityToken();
var data = {
Name: this.picturesFileToUpload.name,
Binary: window.btoa(e.target.result)
};
jQuery.ajax({
url: url,
method: "POST",
contentType: "application/json",
headers: {
"X-CSRF-TOKEN": token
},
data: JSON.stringify(data),
success: this.finishCreateTicket.bind(this),
error: function(jqXHR) {
var error = jqXHR.responseXML.getElementsByTagName("message")[0].innerHTML;
MessageBox.error("The service request was created successfully, but the attachment could not be uploaded: " + error);
this.oDialog.setBusy(false);
}
});
},
The C4C oData service has a collection called ServiceRequestAttachmentFolder that lets you to add attachemnts onto the service tickets. The sample for it is provided in the initial application that sap provides on github
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rozal,
i have not the answer for your question. However, i am curious to know how to you archieve data upload via OData service? Could you provides some information how do you archieve it on the backend side.
Thanks.
Best,
Manjinder
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.