Hello all, I recently noticed that UploadCollection control was set to deprecated in favour of UploadSet control.
I am trying to switch from one to another, but it seems like an impossible task... When uploading or deleting a file uploaded I get the following error message:

this is how my uploadSet looks like in xml code:
<upload:UploadSet uploadEnabled="{= ${FormInputReady} && ${TaxStatus} !== 'M'}" beforeUploadStarts="onUploadSetChange"
afterItemRemoved="onItemRemoved" id="uploadSet" items="{path: 'toAttachments', templateShareable: false}" maxFileNameLength="200"
uploadCompleted="onUploadSetComplete" terminationEnabled="false">
<upload:UploadSetItem visibleRemove="{EntryEnabled}" visibleEdit="false" fileName="{Name}" mediaType="{Mimetype}"
url="{parts:['Area', 'Company', 'Period', 'FormId', 'IdAttachment', 'ItemId'], formatter:'.formatter.formatUploadURL' }">
<upload:attributes>
<ObjectAttribute
title="Uploaded by"
text="{UserFullname}"
active="false"/>
<ObjectAttribute
title="Uploaded on"
text="{ path: 'CreationDate', type: 'sap.ui.model.type.Date', formatOptions: { style: 'short', pattern: 'dd.MM.yyyy - HH:mm' } }"
active="false"/>
</upload:attributes>
</upload:UploadSetItem>
</upload:UploadSet>
And this is what my controller implementation looks like:
onUploadSetChange: function (oEvent) {
var oUploadSet = oEvent.getSource();
var oItemToUpload = oEvent.getParameter("item");
var oCustomerHeaderToken = new sap.ui.core.Item({
key: "x-csrf-token",
text: this.getModel().getSecurityToken()
});
// Header Slug
var oCustomerHeaderSlug = new sap.ui.core.Item({
key: "slug",
text: oItemToUpload.getFileName()
});
oUploadSet.removeAllHeaderFields();
oUploadSet.addHeaderField(oCustomerHeaderToken);
oUploadSet.addHeaderField(oCustomerHeaderSlug);
},
onItemRemoved: function (oEvent) {
this.getModel().remove(oEvent.getParameters().item.getBindingContext().sPath, {
success: this._refreshView.bind(this),
error: jQuery.proxy(this.errorFnDelete, this)
});
},
onUploadSetComplete: function (oEvent) {
var myBundle = this.getView().getModel("i18n").getResourceBundle();
sap.m.MessageToast.show(myBundle.getText("uploadSuccessful"));
this._refreshView();
},
Can you please help me find where this error come from? I have used UploadCollection before and it worked as a charm...
Thank you all
Request clarification before answering.
Hello David,
I checked with both UploadSet and UploadColelction, this is working as expected for me.
Here I am attaching an example for the same implementation.
Also what is the implementation inside this._refreshView()? As this method is not here in my example, it might be causing some problem.
As Margot mentioned, this error occurs when a view gets called more than once.
Can you please share an example where this issue is being reproduced?
Regards,
Amiya Ranjan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Amiya,
Thank you for your example, but it is not quite valid since you are not using an OData service, everything is local and no real upload is made... I have tried a local model and works as your example with no problem, so the issue must be in the OData part...
Also, in your example, the uploaded files never get uploaded and they never get past the incomplete-item status, which would lead you to another issue, which is that incomplete items don't get removed and duplicated items appear (the incomplete item and the uploaded item).
Implementation of _refreshView only refreshes the model ( this.getView().getModel().refresh() ) after a successful upload or a successful delete operation.
I built a sample application with no more than the uploadSet control, with the OData service implemented, and I get the same error. Just a view, a controller, an UploadSet control and the OData service.
Thank you for your help!
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.