Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws s3 uploaded video file cant play, it's download automatically

My video file can uploaded successfully. but i can't play it inside the browser. when i request it automatically downloaded. also i used "content-type: video/mp4" but when i request it's content type is binary/octet-stream

following is my python code.

def get_bucket_sign_url(upload_path):
    try:
        presigned_post = s3_client.generate_presigned_post(
            Bucket=settings.AWS_STORAGE_BUCKET_NAME,
            Key=upload_path",
            Fields={"acl": "public-read", "Content-Type": 'video/mp4'},
            Conditions=[
                {"acl": "public-read"},
                {"Content-Type": 'video/mp4'},
                {"success_action_status": "200"}
            ],
            ExpiresIn=settings.S3_MAX_TIMEOUT # 3600
        )
        return presigned_post
    except Exception:
        return {}

following is my curl code.

curl --location --request POST 'https://******.s3.amazonaws.com/' \
--form 'key=media/customer_videos/5556.mp4' \
--form 'file=@/home/user/Videos/ssm.mp4' \
--form 'acl=public-read' \
--form 'content-type=video/mp4' \
--form 'AWSAccessKeyId=*******' \
--form 'policy=******' \
--form 'signature=******'
like image 893
WAEX Avatar asked Sep 15 '25 06:09

WAEX


1 Answers

Check metadata in uploaded S3. The value field should be video/mp4. Please refer the following screenshot

enter image description here

like image 106
xenowits Avatar answered Sep 17 '25 21:09

xenowits