AWS s3 EntityTooLarge 和 Froala

AWS s3 EntityTooLarge and Froala

我正在使用 Froala 所见即所得编辑器将文件上传到 s3。只要文件小于 20 MB,一切都可以正常工作。我已将 Froala 编辑器设置为接受超过 50 MB 的文件。但是,每当我尝试上传更大的文件时,我都会从 s3 收到以下响应错误:

<Error>
<Code>EntityTooLarge</Code>
<Message>Your proposed upload exceeds the maximum allowed size</Message>
<ProposedSize>20974039</ProposedSize>
<MaxSizeAllowed>20971520</MaxSizeAllowed>
<RequestId>4292DB24BF022FC5</RequestId>
<HostId>C0QRzNxtazcS4NUQwvU89+QblW1MleMbLUNxoEAyjX2EuUmNUKXc3XbV+1K1GagBHOGBHHpB8ho=</HostId>
</Error>

我将文件上传到 s3 设置如下:

fileMaxSize: 60 * 1024 * 1024,
          fileUploadToS3: {
            bucket: "<%= @hash[:bucket] %>",
            region: "s3-us-west-1",
            keyStart: "<%= @hash[:key_start] %>",
            callback: function (url, key) {
            },
            params: {
              acl: "<%= @hash[:acl] %>", // ACL according to Amazon Documentation.
              AWSAccessKeyId: "<%= @hash[:access_key] %>", // Access Key from Amazon.
              policy: "<%= @hash[:policy] %>", // Policy string computed in the backend.
              signature: "<%= @hash[:signature] %>", // Signature computed in the backend.
            }
          }

这似乎是亚马逊的大小,但据我所知,s3 支持每个文件最多上传 5gb。我在这里错过了什么?

在 S3 中上传表单 post 的策略声明包括对 content-length-range 条件键的支持,它指示...

The minimum and maximum allowable size for the uploaded content

http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html#sigv4-PolicyConditions

您的这部分代码没有显示在问题中,但 S3 似乎在抱怨您上传的文件大于您自己的政策允许的最大大小。