S3 problem: missing Content-Length HTTP header

3,605 views
Skip to first unread message

Andrew Stewart

unread,
May 29, 2009, 5:08:13 AM5/29/09
to Paperclip Plugin
Hello,

I am able to upload files successfully using file system storage but I
cannot get S3 storage to work. The logs show these messages:

warning: peer certificate won't be verified in this SSL session
New RightAws::S3Interface using single-threaded mode
Opening new HTTPS connection to s3.amazonaws.com:443
##### RightAws::S3Interface returned an error: 411 Length Required
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>MissingContentLength</Code><Message>You must provide the
Content-Length HTTP header.</Message><RequestId>BDC7C8D234F93A20</
RequestId><HostId>nLfin453Xq
+B52iaOn3Di9HGscMwXAKSZJ90QNwQyowmdjKkf7D7F6d9wbgDHjhb</HostId></
Error> #####
##### RightAws::S3Interface request: s3.amazonaws.com:443/st_andrews/
development ####

RightAws::AwsError (MissingContentLength: You must provide the Content-
Length HTTP header.):
/usr/local/lib/ruby/gems/1.8/gems/right_aws-1.10.0/lib/awsbase/
right_awsbase.rb:359:in `request_info_impl'
/usr/local/lib/ruby/gems/1.8/gems/right_aws-1.10.0/lib/s3/
right_s3_interface.rb:169:in `request_info'
/usr/local/lib/ruby/gems/1.8/gems/right_aws-1.10.0/lib/s3/
right_s3_interface.rb:201:in `create_bucket'
/usr/local/lib/ruby/gems/1.8/gems/right_aws-1.10.0/lib/s3/
right_s3.rb:102:in `bucket'
/vendor/plugins/paperclip/lib/paperclip/storage.rb:164:in
`s3_bucket'
[etc]

And here is my model:

class Talk < ActiveRecord::Base
has_attached_file :notes,
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/
amazon.yml",
:path => "talks/:id/notes/:filename"
end

I have two questions. First and foremost, how can I get this
working? Second, why is RightAws opening an HTTPS connection instead
of an HTTP connection?

My Paperclip is up to date (installed yesterday). I am using the
right_aws gem v1.10.0 and the right_http_connection gem v1.2.4. Rails
2.2.2.

Any help would be much appreciated!

Thanks and regards,

Andy Stewart
--------
http://airbladesoftware.com

Jonathan Yurek

unread,
May 29, 2009, 4:35:29 PM5/29/09
to papercli...@googlegroups.com
You don't seem to have an S3 bucket defined (or is that defined in the
amazon.yml?). That could be confusing RightAWS.

Is it a problem that it's opening an HTTPS connection?
--
Jonathan Yurek, Founder and CTO
thoughtbot, inc.
organic brains. digital solutions.

617.482.1300 x114
http://www.thoughtbot.com/

Andrew Stewart

unread,
May 30, 2009, 6:11:00 AM5/30/09
to papercli...@googlegroups.com

On 29 May 2009, at 21:35, Jonathan Yurek wrote:

> You don't seem to have an S3 bucket defined (or is that defined in the
> amazon.yml?). That could be confusing RightAWS.

Thanks for the reply. The bucket is defined in my amazon.yml:

CREDENTIALS: &CREDENTIALS
access_key_id: ...
secret_access_key: ...

development:
bucket: st_andrews/development
<<: *CREDENTIALS

test:
bucket: st_andrews/test
<<: *CREDENTIALS

production:
bucket: st_andrews/production
<<: *CREDENTIALS


> Is it a problem that it's opening an HTTPS connection?

No, it's not a problem. It surprised me though and I thought it might
be a symptom of whatever's preventing this from working.

Regards,

Andy Stewart

Andrew Stewart

unread,
Jun 1, 2009, 7:22:43 AM6/1/09
to Paperclip Plugin

On 29 May 2009, at 10:08, Andrew Stewart wrote:

> RightAws::AwsError (MissingContentLength: You must provide the
> Content-
> Length HTTP header.):

It seems S3 requires the Content-Length header on various operations,
such as bucket creation, and right_aws v1.10.0 doesn't implement this.

Happily Dilshod fixed this in November last year so I grabbed his
change, made a gem, and replaced RightScale's v1.10.0 with mine.
Everything now works.

http://github.com/airblade/right_aws/commit/e6cf18db65a4921615c88cdf52a14dafe94139d8

Regards,

Andy Stewart
------
http://airbladesoftware.com

Reply all
Reply to author
Forward
0 new messages