Skip to Content

Upload image from SAP UI5 using FileUploader to SAP MIME Repository

Hi Experts,

On click of a button, I want to send an image uploaded using fileuploader in ui5 to sap mime repository in backend.

View:

<Image id="img" densityAware="false" width="10em" height="10em"/>
<uni:FileUploader id="idUpload" 
		 change = "onImgUpload"
		 sendXHR = "true"
		 uploadOnChange = "false"  
		 useMultipart = "false"
		 placeholder="Upload File" 
		uploadComplete="onUploadComplete"/>
 <core:Title/><button text="Submit" width="200px" press="onSubmit"></button>


Controller:

	onSubmit: function(user) {
		var oFileUploader = this.getView().byId("idUpload");
		var oEmpId = this.getView().byId("idEmpID").getValue();
		var oUrl = "/sap/opu/odata/sap/ZSWIPECARD_SRV/zswipeSet";    
		sap.ui.getCore().getModel().refreshSecurityToken();
		var oHeaderParam = new sap.ui.unified.FileUploaderParameter({
			name: "x-csrf-token", 
			value: sap.ui.getCore().getModel().getHeaders()['x-csrf-token']
		});
		var oHeaderParamSlug = new sap.ui.unified.FileUploaderParameter({
			name: "slug", 
			value: oFileUploader.getValue() 
		});
		oFileUploader.addHeaderParameter(oHeaderParam);
		oFileUploader.addHeaderParameter(oHeaderParamSlug);		
		oFileUploader.setUploadUrl(oUrl);
		oFileUploader.upload();    
	},

Entity Type: Images Attached



CREATE_STREAM:
Issue: I do not receive any data in it_key_tab (if i try to send key value through url in onSubmit function it throws POST 400 error).
Issue: I am not able to send data found in is_media_resource to mime.


create-stream.jpg (63.7 kB)
entity.jpg (23.0 kB)
entity2.jpg (37.6 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Mar 07 at 11:24 AM

    Solved by Self.

    Add comment
    10|10000 characters needed characters exceeded