最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - Can I limit the size of an object put into S3 via the JavaScript API? - Stack Overflow

programmeradmin5浏览0评论

It is possible to use JavaScript APIs to upload objects to S3 and it is possible to have a fine-grain authorization using IAM policies. For instance, see this policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "s3:PutObject",
        "s3:PutObjectAcl"
      ],
      "Resource": [
        "arn:aws:s3:::YOUR_BUCKET_NAME/*"
      ],
      "Effect": "Allow"
    },
  ]
}

It is possible to use JavaScript APIs to upload objects to S3 and it is possible to have a fine-grain authorization using IAM policies. For instance, see this policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "s3:PutObject",
        "s3:PutObjectAcl"
      ],
      "Resource": [
        "arn:aws:s3:::YOUR_BUCKET_NAME/*"
      ],
      "Effect": "Allow"
    },
  ]
}

inspired from their tutorial which allows to put objects into the bucket YOUR_BUCKET_NAME. However it is not clear to me whether it is possible to limit the number of objects and the size of each objects one can upload. I have checked into the list of contitions, but I didn't find anything useful on this.

Share Improve this question asked Jul 14, 2015 at 16:29 Davide VernizziDavide Vernizzi 1,40719 silver badges26 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Is it possible to limit the number of objects and the size of each object one can upload to S3? In general, no. You cannot do this through any kind of bucket policy.

You can, however, limit an individual object upload size from browsers using a pre-signed POST URL with a policy indicating a content-length-range.

Alternatively, you could code this restriction into your JS client or a server that proxies your uploads.

See JS examples and a discussion of policies and a related response on restricting object size via POST.

In reply to the title "Can I limit the size of an object put into S3 via the JavaScript API?"

Yes you can. But instead of using IAM, use createPresignedPost. In Conditions specify a maximum content-length-range.

发布评论

评论列表(0)

  1. 暂无评论