cancel
Showing results for 
Search instead for 
Did you mean: 

Problem when Upload file from SAPUI5 App to Gateway - wrong xstring value

joo_mariano2
Participant
0 Kudos
588

Hello All.

I'm creating an App to upload files into SAP DMS.

I read many blogs showing how to do it. So, first I created an OData Service and implemented the CREATE_STREAM method.

When I test the service through GW_CLIENT, the file is upload successful and I can see it in CV03N:

GW_CLIENT:

CV03N:

File Content in MS Word:

Well, in my UI5 app, I call the OData Service through ajax. The "data" parameter in ajax call have the same length when I call the OData service through GW_CLIENT (640747):

Ajax Call:

GW_CLIENT: (IS_MEDIA_RESOURCE-VALUE)

But after the ajax call, the length of IS_MEDIA_RESOURCE-VALUE is to bigger than when the call is do through GW_CLIENT:

So, when I save this content as a File in DMS, the file is corrupt an it cannot be open through MS Word.

When the file is pure TXT format, the operation is sussecsful.

My ajax call:

$.ajaxSetup({cache: false});
jQuery.ajax({
  url: "/sap/opu/odata/sap/ZSG_FI_SOLCRED_SRV/fileSet",
  processData: false,
  async: false,
  data: file.Content,
  dataType: file.MimeType,//"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
  type: "POST",
  beforeSend: function(xhr){
    xhr.setRequestHeader("X-CSRF-Token", that.token);
    xhr.setRequestHeader("Content-Type", file.MimeType);
    xhr.setRequestHeader("slug", slug);
  },
  success: function(oData){
    that.message("File Ok");
  },
  error: function(error){
    that.message("F");
  }
});

I would to like to know why the content of IS_MEDIA_RESOURCE-VALUE comes different through GW_CLIENT and Ajax Client? And how to fix it.

Thanks for advance.

BR,

João Mariano

Accepted Solutions (0)

Answers (0)