on 2023 Sep 04 1:25 PM
Hi Experts,
I am using Uploadset UI5 control for attaching docs. I have "Submit" button to send the attachment to backend.
In my controller when i use the below code,
var serviceurl = "/sap/opu/odata/sap/ZI_XX_SRV/";
var oModel = new sap.ui.model.odata.v2.ODataModel(serviceurl);
//Locate base64 content//
var base64Index = e.target.result.indexOf(base64_marker) + base64_marker.length;
// Get base 64 content//
var base64 = e.target.result.substring(base64Index);
oFileRaw.data = base64;
var mHeaders = {
"slug": oController.byId("UploadSet3").getHeaderFields()[1].getText().split("|")[0],
"Content-Type": oController.byId("UploadSet3").getHeaderFields()[2].getText()
};
oModel.setHeaders(mHeaders);
oModel.create(entityset, payLoad, {
success: function (oData, response) {
debugger;
alert("yes");
},
error: function (response) {
debugger;
alert("No");
}
});
It doesnot trigger the backend call and gives error "no hadler for data".
So now i am making the oModel change (removing v2) .
var oModel = new sap.ui.model.odata.ODataModel(serviceurl);
Now my odata is triggering, i am getting only slug & content type in headers but my content in payload is not receiving in backend.
So now i have commented my code
//var mHeaders = {
// "slug": oController.byId("UploadSet3").getHeaderFields()[1].getText().split("|")[0],
// "Content-Type": oController.byId("UploadSet3").getHeaderFields()[2].getText()
// };
//oModel.setHeaders(mHeaders);
Now in backend i am getting my payload but i am not getting my headers since i have commented.
How should i receive both headers(slug & Content type) and payload in a single call? Do i need to use "v2" in my odata service or not?
Please help how to resolve this issue
Thanks,
Gowtham
Request clarification before answering.
Hi,
You shouldn't create the request yourself but use the method upload and the control will trigger it automatically.
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if we use upload url then it will call the back end automatically I don’t want to do that because end user may attach docs and they may delete that also so if I use uploadurl then the attachments will be uploaded to back end. I don’t want to do that once user finalise the docs to send them I have introduced submit button to trigger back end call
Hi gowtham.raja,
If I understood correctly, your requirement can be handled by setting the property instantUpload = false:
Defines whether the upload process should be triggered as soon as the file is added.
If set to false
, no upload is triggered when a file is added.
Then, in your submit button call the upload method.
Alex
User | Count |
---|---|
89 | |
11 | |
9 | |
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.