sanderl-mediamonks
9/15/2017 - 8:47 AM

Add download header (Content-Disposition) to file stored in s3 with django storages

Add download header (Content-Disposition) to file stored in s3 with django storages

# generate download link by adding content disposition header
s3storage = model_instance.video_file.storage
s3storage.querystring_auth = True
s3storage.custom_domain = None
video_download_url = s3storage.url(
    model_instance.video_file.name,
    parameters={'ResponseContentDisposition': 'attachment;filename="your-visatiff-video.mp4"'}
)
s3storage.querystring_auth = False
s3storage.custom_domain = settings.AWS_S3_CUSTOM_DOMAIN