S3预先签名的POST验证文件类型?

时间:2016-08-30 11:47:08

标签: amazon-web-services amazon-s3

我知道可以使用content-length-range标头限制文件大小。但是可以验证文件类型吗?

https://docs.aws.amazon.com/AmazonS3/latest/dev/HTTPPOSTForms.html#PolicyConditions

我看到有一个Content-Type标头,如果我这样说,audio/mp3只会允许MP3文件并在文件不是mp3时返回错误?

我找到了上一个问题,但答案只提到验证文件大小:s3 direct upload restricting file size and type

1 个答案:

答案 0 :(得分:1)

您可以在POST请求中指定Content-Type。

您也可以在签名处指定它,因此必须使用该Content-Type:

完成帖子
{ "expiration": "2007-12-01T12:00:00.000Z",
  "conditions": [
    {"acl": "public-read" },
    {"bucket": "johnsmith" },
    {"Content-Type: "audio/mp3"}
  ]
}

Creating an HTML Form (Using AWS Signature Version 4)

编辑:在您找到的上一个问题中,他们实际上正在检查内容类型。

相关问题