Skip to Content

Upload DOCX or XLSX file from SAPUI5, file is corrupted

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Nov 22, 2016 at 01:47 PM

    what is your sever side implementation/code?

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 17, 2017 at 05:52 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 29, 2017 at 04:54 PM

    Hi,

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

    Regards,

    Melwyn

    Add comment
    10|10000 characters needed characters exceeded