[Box Connector] File upload API with chinese characters in filename messes up the filename

[Box Connector] File upload API with chinese characters in filename messes up the filename

  
Forge Component
(6)
Published on 2017-08-11 by OutSystems R&D
6 votes
Published on 2017-08-11 by OutSystems R&D

Hi all,

We are using the File Upload API of Box Connector to upload files to Box. However, if the filename contains Chinese characters, the uploaded file in Box does not have the proper filename and instead displays them as question marks("???"). 

Any idea what is wrong? Note that Box Web interface properly supports uploading of files with Chinese characters in their names. Is there any other way to specify the filename in the API? 

Requesting for your support.

Regards,

Vikrant 

Hi Vikrant,

Though I'm not too familiar with Box or the Box Connector, the component uses the Box API 2.0, as documented here. For the "Upload file" method, the documentation reads:

Supported File Names:

Box only supports file names of 255 characters or less. Names that will not be supported are those that contain non-printable ascii, / or \, names with trailing spaces, and the special names “.” and “..”.

Since they are talking about "non-printable ascii" and since they don't mention Unicode or UTF-8 at all, I fear that they don't support it properly in their API.

Did you increase the logging level of the REST API to see what is actually sent to Box?



Hi Kilian,

Thanks for the pointers. 

We noticed that the Box Connector module is actually sending "???" as filename to Box instead of the actual Chinese characters, probably due to the TextToBinaryData conversion used in the "File_Upload" action. 

We then replaced only the FileName string with the UTF-8 converted FileName string in the "File_Upload" action while composing the binary request body. The rest of the binary data is created with default encoding, except for FileName string which is created with UTF-8 encoding. This change actually worked fine and we could see the Chinese characters in the filename of the uploaded file in Box.

Could the Box Connector team check if this is the correct fix and then update the Box Connector code?

Thanks and regards,

Vikrant Sharma

It's good to know that you got it working. You're right, the TextToBinaryData might be the problem, as there's no encoding specified. Did you try to add "utf-8" as second parameter to see if it works then?

Hi Kilian,

We added utf-8 as a second parameter only for the actual Filename string. The rest of the body is still encoded with default encoding.

Regards,

Vikrant Sharma

Box Connector Team,

Could you please verify the suggested fix and please provide an updated version of the Box Connector with the fix?

Regards,

Vikrant Sharma


Hello,

I am testing version 2.0.5.
I encounterd the same trouble using Japanese charactors in file name.

In the box's document describes "attributes" entry for multipart/form-data as below.
And you can see the example of this entry in the sample code part of the document.

The request body uses the "multipart/form-data" format to transmit two "parts". The first part is called "attributes" and contains a JSON object with information about the file, including the name of the file and the ID of the parent folder. The second part contains the contents of the file. (Note that the name of the second "part" is ignored.)

https://developer.box.com/reference#upload-a-file

When using the "attributes" entry instead of the implementation of ver.2.0.5, the trouble disappeared.

I am waiting for a corrected new version.
Introducing the module to Japanese customers becomes easier for when the new version will be released.