AWS s3 EntityTooLarge和Froala

时间:2016-11-22 19:41:54

标签: amazon-s3 froala

我正在使用Froala WYSIWYG编辑器将​​文件上传到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的上传。我在这里缺少什么?

1 个答案:

答案 0 :(得分:1)

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

  

上传内容的最小和最大允许尺寸

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

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