0
votes

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?

1
Your // Policy string computed in the backend can include a "content length range" that limits the size of any upload. Take a look at what you're using for the policy document and maybe include an example in the question so we can rule that in or out?Michael - sqlbot
WOW. You just solved my problem. You have no idea how long I spent trying to fix this. THANK YOU.Lorenz

1 Answers

1
votes

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.