0

Before I beign, I tried the solution on Amazon S3 Change file download name but, I am still getting the same issue.

I have a publicly available file stored in an S3 bucket. The key prefix is set to some guid that looks like the fllowing. enter image description here

Since this file is publicly available(this is a requirement), anyone will be able to download it directly via the S3 url. Now, my problem is, whenever the file is downloaded via the bucket url the filename is set to the same GUID.

Based on internet searches, I modified the Content-Disposition meta data of each files on the bucket with filename property set hoping the download filename would be updated to what I set via meta data but, the problem still persists. Meta data for the file looks like the following.

enter image description here

I expected to get test_file.pdf. istead of bf13b0d10f9959f68c08b182f65823eff6cb84f7.pdf when I download via direct url.

My application is not generating pre-signed url for these objects so, I have a less control over it.

Is this even possible? Do I need to upload the whole thing with proper filename? Any help will be appreciated.

Mahesh Nepal
  • 1,385
  • 11
  • 16

1 Answers1

0

Use the Content-Disposition header instead of using x-amz-meta-content-disposition.

Check my example below:

  1. I uploaded the file with the name new_file.txt:

enter image description here

  1. I added the Content-Disposition header in the metadata to change the file name to my_file.txt:

enter image description here

  1. And when I download the file it shows me the name new_file.txt:

enter image description here

Raul Barreto
  • 979
  • 5
  • 9