cancel
Showing results for 
Search instead for 
Did you mean: 

How can we replace UploadCollection with UploadSet?

0 Kudos

How can we replace UploadCollection with UploadSet? The events used in UploadCollection and UploadSet are different. For ex I try using 'AfterItemAdded' instead of 'change' and the oEvent is different for both these events. Can you please suggest?

    1. mParameters:
    1. files: FileList {0: File, length: 1}
    2. getParameter: ƒ (t)
    3. getParameters: ƒ ()
    4. id: "idCreate--UploadCollection"
    5. mParameters: {id: 'idCreate--UploadCollection-1-uploader', newValue: '"6thOct_TicketList.xlsx" ', files: FileList}
    6. [[Prototype]]: Object
  1. oSource: constructor {bAllowTextSelection: true, mEventRegistry: {…}, sId: 'idCreate--UploadCollection', mProperties: t, mAggregations: {…}, …}
  2. sId: "change"
  3. [[Prototype]]: constructor
  4. mParameters:
    1. id: "idCreate--UploadCollection"
    2. item: c
    1. aBeforeDelegates: []
    2. aDelegates: []
    3. aPropagationListeners: []
    4. iSuppressInvalidate: 0
    5. mAggregations: {dependents: Array(1), tooltip: null}
    6. mAssociations: {}
    7. mBindingInfos: {}
    8. mElementBindingContexts: {}
    9. mEventRegistry: {}
    10. mObjectBindingInfos: {}
    11. mProperties: t {uploadState: 'Ready', mediaType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', fileName: '6thOct_TicketList.xlsx'}
    12. mSkipPropagation: {}
    13. oBindingContexts: {}
    14. oModels: {}
    15. oParent: c {bAllowTextSelection: true, mEventRegistry: {…}, sId: 'idCreate--UploadCollection', mProperties: t, mAggregations: {…}, …}
    16. oPropagatedProperties: {oModels: {…}, oBindingContexts: {…}, aPropagationListeners: Array(0)}
    17. sId: "__item23"
    18. sParentAggregationName: "incompleteItems"
    19. _bContainsError: false
    20. _bFileTypeRestricted: false
    21. _bInEditMode: false
    22. _bIsOwnerActive: true
    23. _bMediaTypeRestricted: false
    24. _bNameLengthRestricted: 0
    25. _bSizeRestricted: 0
    26. _fFileSize: 0.011478424072265625
    27. _iRenderingDelegateCount: 0
    28. _oCancelRenameButton: null
    29. _oConfirmRenameButton: null
    30. _oContextualSettings: {}
    31. _oDeleteButton: null

Accepted Solutions (0)

Answers (1)

Answers (1)

AlexNecula
Active Contributor
0 Kudos

Hi Mehak,

I don't understand what exactly is the issue.

Yes, UploadCollection can be replaced by UploadSet (actually recommended since the former is deprecated), but it's not just a thing of replacing the XML tag. If you have custom logic in the UploadCollection events, you have to decide which events should be used in UploadSet depending on what the requirement is.

If you're asking where to put the CSRF and SLUG headers, use beforeUploadStarts event like below. Note that Item refers to sap.ui.core.Item.

onBeforeUploadStarts: function (oEvent) {
	let oUploadSetItem = oEvent.getParameter("item");
	let sFileName = oUploadSetItem.getFileName();

	oUploadSetItem.addHeaderField(new Item({
		key: "X-CSRF-Token",
		text: this.getOwnerComponent().getModel().getSecurityToken()
	})).addHeaderField(new Item({
		key: "SLUG",
		text: sFileName
	}));
}

Alex