For small files, say < 5Mb, uploading to S3 via a presigned URL is working fine. When I try to upload anything larger than this then, I seem to get 400 Bad Request
responses from S3 with RequestTimeout
as the error.
I'm able to recreate this using curl:
# Create a test file:
mkfile -n 20m ./testfile
# Get the presigned URL
curl -XPOST http://localhost:3000/uploads -d "filename=testdata"
# Upload to S3
curl -H "Content-Type: binary/octet-stream" -XPUT -vvv -T testfile "<Presigned URL>"
Signing code looks like this:
@presigned_url ||= Aws::S3::Presigner.new.presigned_url(
:put_object,
bucket: ENV['AWS_BUCKET'],
key: key,
acl: 'private',
expires_in: 3600,
content_type: 'binary/octet-stream'
)
Note that this all works fine for files < 5Mb, with more frequent failures occurring as the file size increases. Has anyone seen these issues and resolved them?