Attachment names uploaded with Asana API are garbled on AsanaWeb

By integrating our web system with Asana,
we have made we can create tasks and attach files to tasks from the web system side .

However, since early December, files attached to Asana have garbled filenames.
(We use Japanese for files)

We use Java source distributed on GitHub for file attachment processing,
“createOnTask” in this URL.

I have confirmed that I am passing the correct string to fileName,
When attached to Asana, the Japanese is garbled.

Our server processing has not changed before and after the phenomenon.

If you are experiencing the same situation,
Does anyone have a solution?

Hi @TT-TMC , I just tried the same in our application and I confirm that filename is garbage after upload.

But, I have no idea if it was ok before, I don’t remember if we tested with complex utf-8 filenames.

But, that’s something I need to look on our side. Maybe we should add a utf-8 encoding headers somewhere I suppose.

Hi @Frederic_Malenfant ,When specifying a file name with Content-Disposition,
It was improved by adding UTF-8 encoding header.
We really appreciate your infomation.

    public ItemRequest<Attachment> createOnTask(String task, InputStream fileContent, String fileName, String fileType) {
        String encFileName = fileName;
        try {
            encFileName = URLEncoder.encode(fileName, "UTF-8").replace("+", "%20");
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }

        MultipartContent.Part part = new MultipartContent.Part()
                .setContent(new InputStreamContent(fileType, fileContent))
                .setHeaders(new HttpHeaders().set(
                        "Content-Disposition",
                        String.format("form-data; name=\"file\"; filename*=UTF-8''%s", encFileName)
//                        String.format("form-data; name=\"file\"; filename=\"%s\"", fileName) // TODO: escape fileName?
                ));
1 Like

Same behaviour on me using the python-asana library (version=3.0.0).

Giving the param file_name some greek characters, the filename of the attachment file uploaded to Asana has wrong encoding.

Request:

client.attachments.create_attachment_for_task(
    task_id=data['task_id'],
    file_content=attachment,
    file_name='τεστ συνημμένο',
    file_content_type=attachment.content_type,
    opt_pretty=True
)

Asana attachment filename stored:

τεστ συνημμένο

Note that posting the same request using Postman, the attachment filename is stored with the correct encoding in the Asana task.