IQSS / IQSS/dataverse

Uploading non-ascii filenames through the API results in bad filename

Open
#12,470 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
Java
Stars
1.1k
Forks
564
Avg merge
2d 2h
Merged PRs (30d)
29

Description

What steps does it take to reproduce the issue?
Upload a file with a non-ascii (e.g. accented, like öüóőúűéáíä.txt) name with the API.

curl -H "X-Dataverse-key:$API_TOKEN" -X POST -F "file=@$FILENAME" "$SERVER_URL/api/datasets/:persistentId/add?persistentId=$PERSISTENT_ID"
I also tried adding -H "Content-Type: multipart/form-data; charset=utf-8", with the same result.

What did you expect to happen?
The file name should be the same as the uploaded file.

What happened
The filename is stored garbled, seemed the same as if someone interpreted the UTF-8 chars as ISO-8859-1 (öüóÅúűéáäí.txt in the above case).
This command seems to yield the same distortion:

$ echo öüóőúűéáäí | konwert iso1-utf8
öüóÅúűéáäÃ

Which version of Dataverse are you using?
6.9, but I tried others as well.

Are you thinking about creating a pull request for this issue?
I am not sure yet.

Workaround
You can call a rename (POST /api/datasets/:persistentId/files/metadata API call or update_datafile_metadata() in pydataverse) after upload to rename the file. I am currently implementing this in my DataverseMassUploader.

Discussion
See also #community > api curl upload utf-8 filenames @ 💬

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the upload through POST /api/datasets/:persistentId/add with a non-ASCII filename, then trace the API's multipart filename handling. Compare the stored name with the original UTF-8 name and verify that the upload preserves it without requiring the metadata rename workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.