Quick note: running into timeouts when uploading photos to S3 using attachment_fu on EC2 (that’s a mouthful)?
I think I tracked down the problem. Actually, I tracked down someone else who tracked down the problem: http://rubyforge.org/pipermail/amazon-s3-dev/2007-April/000072.html
Turns out the default for the aws/s3 library is to use persistent connections, which apparently cause intermittent timeouts.
Solution: use non-persistent connections by doing this in your attachment_fu/backends/s3_backend.rb:
Base.establish_connection!(
:access_key_id => s3_config[:access_key_id],
:secret_access_key => s3_config[:secret_access_key],
:server => s3_config[:server],
:port => s3_config[:port],
:use_ssl => s3_config[:use_ssl],
:persistent => s3_config[:use_persistent]
)
Then you can add a line to your amazon_s3.yml like this:
production:
bucket_name: your_app_production
access_key_id: 'YOUR_ACCESS_KEY_ID'
secret_access_key: 'YOUR_SECRET_ACCESS_KEY'
use_persistent: false
