I am trying to upload a file to S3 with the following simple code:
bucket.objects.create("sitemaps/event/#{file_name}", open(file))
I get the following:
Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
What could be going wrong? Any tips will be appreciated.
This timeout is generally happens when the content length could not be correctly determined based on the opened file. S3 is waiting for additional bytes that aren’t coming. The fix is pretty simple, just open your file in binary mode.
Ruby 1.9
Ruby 1.8
The aws-sdk gem will handle this for you if you pass in the the path to the file:
Also, you can write to an object in s3 before it exists, so you could also do:
Hope this helps.