Reputation: 131
After uploading the video(.mp4) file S3 metadata sets its Content-Type : binary/octet-stream when makes my browser force to download the file instead of playing In order to make it play in browser i need to change that content-type programmatically to "video/mp4" in django
Upvotes: 0
Views: 1295
Reputation: 131
After giving lots of hours i come to solution: {
def presign_post_S3_url(self, key=None, is_public=False):
acl = 'private'
if is_public:
acl = 'public-read'
fields = {"acl": acl, "Content-Type": "video/mp4"}
conditions = [
{"acl": acl},
["starts-with", "$Content-Type", ""]
]
if key is None:
return ""
##s3_client is boto3.client object
s3_client = self.get_s3_client()
if s3_client is None:
return ""
data = s3_client.generate_presigned_post(
Bucket=self.bucket,
Key=key,
Fields=fields,
Conditions=conditions
)
return data
Upvotes: 6