【问题标题】:aws s3 uploaded video file cant play, it's download automaticallyaws s3上传的视频文件无法播放,自动下载
【发布时间】:2020-11-17 23:09:36
【问题描述】:

我的视频文件可以成功上传。但我无法在浏览器中播放。 当我要求它自动下载时。 我也使用了“内容类型:视频/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 代码。

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

【问题讨论】:

标签: python amazon-s3 boto3


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-06-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-19
    • 2018-09-30
    • 2012-10-20
    • 2019-09-17
    • 2021-10-24
    相关资源
    最近更新 更多