cancel
Showing results for 
Search instead for 
Did you mean: 

Upload DOCX or XLSX file from SAPUI5, file is corrupted

mjbelcourt
Explorer
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Hi,

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

Regards,

Melwyn

former_member296513
Discoverer
0 Kudos

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.

junwu
Active Contributor
0 Kudos

what is your sever side implementation/code?