Skip to content


Subversion checkout URL

You can clone with
Download ZIP


boto.s3.key.Key.set_contents_from_filename() incorrectly urlencodes 'attachment; filename=""' header value #1381

dpapathanasiou opened this Issue · 1 comment

1 participant


I have Content-Disposition header values that look like this:

attachment; filename*=UTF-8''My Human-Readable Filename.pdf

But when I view the metadata information on the S3 console, after uploading, it has
been urlencoded like this:


So when I download the file, it ignores the Content-Disposition header entirely, which defeats the purpose of having it.

Any way of getting boto to pass the Content-Disposition value correctly?

Here's what I'm doing currently:

    # create a key to keep track of our file in the storage 
    k = Key(bucket)
    k.key = file_base_name(filename)
    # set the content-disposition so that when downloaded it has the human readable title instead of the pdf uuid
    content_disposition = u''.join(["attachment; filename*=UTF-8''", human_readable_filename, '.pdf'])
    k.set_contents_from_filename(filename, headers={'Content-Disposition':content_disposition}) # but adds unwanted urlencoding :(

    # make it public so it can be accessed
    # using a URL like

There's a partial answer to this problem (thanks to Tony for suggesting it):

But it remains unresolved for file names which require unicode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.