We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

hhting's avatar
hhting
Explorer | Level 4
5 months ago

Upload/Download files with non-printable char

Hi,

We use following apis to perform file upload/download, and passing filename in Dropbox-API-Arg header.

If the filename contains non-printable char (ascii < 32), we encode them using unicode. (according to this encoding doc)

However, this method is only valid for uploading files, downloading files will result in a malformed path error.

How can we properly encode filenames with non-printable char?

 

APIs

- https://content.dropboxapi.com/2/files/download

- https://content.dropboxapi.com/2/files/upload

 


  • hhting wrote:

    ...

    If the filename contains non-printable char (ascii < 32), we encode them using unicode. (according to this encoding doc)

    ...


    Hi hhting,

    Since Dropbox API uses JSON encoding (RFC4627), you need to encode all codepoints < 32, as described in documentation:


    ...

    The representation of strings is similar to conventions used in the C
    family of programming languages. A string begins and ends with
    quotation marks. All Unicode characters may be placed within the
    quotation marks except for the characters that must be escaped:
    quotation mark, reverse solidus, and the control characters (U+0000
    through U+001F).


    By the way, in spite supported by API, it's never good idea such chars to be used since may make Dropbox application confusion (and usually do) - as seems Dropbox application coders are newbee. If possible, try avoid them.

     


    hhting wrote:

    ...

    However, this method is only valid for uploading files, downloading files will result in a malformed path error.

    ...


    Can you give some examples of such calls that are able to upload something, but while you use the same name/path, they cannot get it back? 🤔 What's the exact name?

    • hhting's avatar
      hhting
      Explorer | Level 4

      Hi Ð—дравко,
      We noticed that there are some bugs in our encoding mechanism. We will fix them and see if the problem still exists.
      Thanks

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API

Make connections with other developers

795 PostsLatest Activity: 7 days ago
193 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!