Search code examples
amazon-s3http-headersnon-ascii-characters

response-content-disposition query parameter filename encoding


I need to change the download or open filename of an object on S3. Naturally I use the response-content-disposition query parameter and use the filename field. However I have been able to only use ASCII encoding and this becomes a problem when I need my filenames to be in alphabets with non ASCII characters like Japanese, Korean, Russian, Greek etc. I could not get the filename* field to work with S3. Is there a workaround here to get filenames with non-ASCII characters?


Solution

  • Try to use double encoding. Your content-disposition header looks like below: Open: 'inline; filename=' + EncodingUtil.urlEncode(filename, 'ASCII') + '; filename*=UTF-8\'\'%85%A3%E3%A2%8F'

    Download: 'attachment; filename=' + EncodingUtil.urlEncode(filename, 'ASCII') + '; filename*=UTF-8\'\'%85%A3%E3%A2%8F'

    Please mark this as Best Answer if this works for you