aws s3上传的视频文件无法播放,它会自动下载

时间:2020-07-28 13:30:59

标签: python amazon-s3 boto3

我的视频文件可以成功上传。但我无法在浏览器中播放。 当我要求它自动下载时。 我也使用了“内容类型:视频/ mp4”,但是当我请求时,它的内容类型是二进制/八位字节流

以下是我的python代码。

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 {}

以下是我的卷曲代码。

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

1 个答案:

答案 0 :(得分:0)

检查上传的 S3 中的 metadata。值字段应为 video/mp4。请参考以下截图

enter image description here