× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Forcing a file to be downloaded instead of streamed from CloudFront/S3

Beau Simensen
Apr 22, 2015
<p>Some file types, especially media file types, will be streamed from CloudFront/S3 unless you set the proper headers on the obects in the S3 bucket directly. In this case, it means setting "Content-Disposition: attachment; filename=filename.ext" on the object.</p> <p>If you need to allow for both download files and streaming of the same content this means you have to have two copies of the same object. One with no Content-Disposition header and one with the Content-Disposition header.</p> <p>If this is not doable, a workaround can be to create a file to download the files from CloudFront/S3 and serving the files with the correct headers. There are many downsides to this approach but if the requirement is there to have the download dialog come up and you cannot adjust the CloudFront/S3 headers, this may be your only option.</p>
comments powered by Disqus