Skip to Content
0

Upload DOCX or XLSX file from SAPUI5, file is corrupted

Nov 21, 2016 at 05:46 PM

554

avatar image
Former Member

Hello,

I am new to Fiori and I have a Fiori like application that upload different type of files into DMS Kpro. We have some problems when the user upload DOCX or XLSX. The file is save in Kpro and when we try to access it with CV02N,

XLSX --> I get unknown characters

DOCX --> I have a message saying the file is corrupted and I clicked on ok. Then, I get a message saying that the file has unreadable characters and I click on yes and the file open and it is readable.

There is no problem when the user upload files from the Fiori like application with these types ".pdf" ".xls" ".doc" ".jpg" ".png" ".jpeg" ".tif"

There is no problem if the user upload a XLSX or DOCX from SAP transaction.

The problem happens only when the file XLSX or DOCX is uploaded from Fiori like application and I open it in CV02N in SAP.

The user can open the DOCX or XLSX in Fiori like application without any problem.

Here is the upload in SAPUI5

this.getModel().refreshSecurityToken(jQuery.proxy(function(){

var oRequest = this.getModel()._createRequest();

var oHeaders = {

"x-csrf-token": oRequest.headers['x-csrf-token'],

"slug": this.getSlug(),

};

jQuery.ajax({

type: 'POST',

url: this.getUploadUrl(),

headers: oHeaders,

cache: false,

contentType: file.type,

processData: false,

data: file.files[0],

success: _handleSuccess,

error: _handleError

});

jQuery.sap.log.info("File uploading to " + this.getUploadUrl());

},this),function(){console.log("failure");},

true);

In the gateway, the program calls a custom function that use 'SCMS_XSTRING_TO_BINARY' to convert the content of the file and then, it saves it to Unix.

I search on the forum but I was not able to solve it. Could you please help me figure out why it does not work with DOCX or XLSX?

Thank you in advance for your help

MJ

unknown-char.jpg (28.2 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Jun Wu Nov 22, 2016 at 01:47 PM
0

what is your sever side implementation/code?

Share
10 |10000 characters needed characters left characters exceeded
Sushil Kumar Yadav Jan 17, 2017 at 05:52 AM
0

Your XLSX data is getting converted to Unicode (the unknown characters in image is unicode data) when it is read by FileUploader/FileUpload Collection. You need to convert that Unicode data to String. For conversion you can use jszip & xlsx.js third party javascript library.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Apr 29, 2017 at 04:54 PM
0

Hi,

Were you able to solve this and if so can you share the solution ?

Regards,

Melwyn

Share
10 |10000 characters needed characters left characters exceeded