Skip to Content
0
May 04, 2018 at 04:57 PM

Send cordova picture to SAP Gateway

227 Views

Hello all,

I know there is a lot of posts on this topic but I could not find a solution for my problem.

I create a hybrid app with the possibility to take picture with

navigator.camera.getPicture(function(imageData){
  var M = t.getView().getModel();
  var picture = {};
  var myImage = t.getView().byId("myImage");
      myImage.setSrc(imageData);
      picture.PictureContent = imageData.substring(22);
      M.createEntry("/PictureSet", picture);
			}, function(message) {
				MessageToast.show(message, {
					closeOnBrowserNavigation: false
				});
			}, {
			quality: 50,
			saveToPhotoAlbum: false,
			sourceType: navigator.camera.PictureSourceType.CAMERA,
			destinationType: navigator.camera.DestinationType.FILE_URI

			});

When the result is successful I add the picture to my Odata :

var picture = {};
var myImage = t.getView().byId("myImage");
myImage.setSrc(imageData);
picture.PictureContent = imageData.substring(22);
picture.headers = {
"slug": "FileName=" + "image.png"
};
M.createEntry("/PictureSet", picture);

The entity Picture is checked as 'Media'

When I look at the POST request, the content-type of my request is 'application/json' and not 'image/png' and in method CREATE_STREAM the field IS_MEDIA_RESOURCE-VALUE doesn't contain the picture but the odata uri :

I don't find any solution, could you please help me ?

Thank you for your help.

Best regards,

Mikaël.

Attachments