Search code examples
amazon-s3froala

AWS s3 EntityTooLarge and Froala


I am using the Froala WYSIWYG editor to upload files to s3. Everything works fine as long as the files are less than 20 mb. I have set the Froala editor to accept files over 50 mb. However, whenever I try to upload a larger file I get the following response error from 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>

I have file upload to s3 set up as follows:

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.
            }
          }

It seems to be something from Amazon's size, but as far as I can tell, s3 supports uploads up to 5gb per file. What am I missing here?


Solution

  • The policy statement for form post uploads in S3 includes support for a content-length-range condition key, which dictates...

    The minimum and maximum allowable size for the uploaded content

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

    This part of your code is not shown in the question, but S3 appears to be complaining that you are uploading a file that is larger than the maximum size your own policy allows.