1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

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

Discussão em 'Python' iniciado por Stack, Outubro 4, 2024 às 06:22.

  1. Stack

    Stack Membro Participativo

    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=******'

    Continue reading...

Compartilhe esta Página