Skip to Content
0
May 21, 2020 at 12:35 PM

UploadCollection is throwing error while uploading a file using .xsjs

222 Views

Hello All,

I am uploading a file using UploadCollection but it is throwing me an error "Unexpected end of MIME multipart stream. MIME multipart message is not complete", Same file is uploaded using FileUploader but in case of uploadCollection it is throwing above error.

onStartUpload: function(oEvent) {
			var oUploadCollection = this.byId("UploadCollection");
			var cFiles = oUploadCollection.getItems().length;
			var uploadInfo = cFiles + " file(s)";
			if (cFiles > 0) {
				oUploadCollection.upload();
                                MessageToast.show("Method Upload is called (" + uploadInfo + ")");	
			}
		},

	onChange: function(oEvent) {
			var oUploadCollection = oEvent.getSource();			
    		oUploadCollection.removeAllHeaderParameters();
			
    		oUploadCollection.addHeaderParameter(new sap.m.UploadCollectionParameter({
    		name: "x-csrf-token",
    		value: "x-csrf-token"	}));
			
         },  

	onBeforeUploadStarts: function(oEvent) {
			
			var oUploadCollection = oEvent.getSource();
			
    		var oItems = oUploadCollection.getItems();
    		var sSlug = "";
    		var sSep = ", "; //separation
    		
    		for( var i = 0; i< oItems.length; i++ ) {
    		
    			sSlug +=  oItems[i].getFileName() + sSep;
    			
    		}
    		
    		var oCustomerHeaderSlug = new sap.m.UploadCollectionParameter({
        			name: "slug", value: sSlug });
	
    		oEvent.getParameters().addHeaderParameter(oCustomerHeaderSlug);
    		
		}