A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/fog/fog-aws/issues/428 below:

Unable to use fog-aws with DigitalOcean Spaces: MissingContentLength · Issue #428 · fog/fog-aws · GitHub

Here is my test script:

require 'rubygems'
require 'fog-aws'

# create a connection
connection = Fog::Storage.new({
  :provider                 => 'AWS',
  :region => 'ams3',
  :aws_access_key_id        => 'my-access-key',
  :aws_secret_access_key    => 'my-secret-key',
  :endpoint => 'https://ams3.digitaloceanspaces.com'
})

directory = connection.directories.get('stanhu-test')

file = directory.files.create(
  :key    => 'unicorn.txt',
  :body   => File.open("/tmp/unicorn.txt"),
  :public => true,
  :length => 45602
)

When I do this, I see:

/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/middlewares/expects.rb:7:in `response_call': Expected(200) <=> Actual(411 Length Required) (Excon::Error::LengthRequired)
excon.error.response
  :body          => "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Error><Code>MissingContentLength</Code><BucketName>stanhu-test</BucketName><RequestId>tx000000000000002f88c3b-005a6055c4-aec4-ams3a</RequestId><HostId>aec4-ams3a-ams3</HostId></Error>"
  :cookies       => [
  ]
  :headers       => {
    "Accept-Ranges"             => "bytes"
    "Content-Length"            => "222"
    "Content-Type"              => "application/xml"
    "Date"                      => "Thu, 18 Jan 2018 08:07:32 GMT"
    "Strict-Transport-Security" => "max-age=15552000; includeSubDomains; preload"
    "x-amz-request-id"          => "tx000000000000002f88c3b-005a6055c4-aec4-ams3a"
  }
  :host          => "ams3.digitaloceanspaces.com"
  :local_address => "10.138.0.7"
  :local_port    => 52494
  :path          => "/stanhu-test/unicorn.txt"
  :port          => 443
  :reason_phrase => "Length Required"
  :remote_ip     => "5.101.110.225"
  :status        => 411
  :status_line   => "HTTP/1.1 411 Length Required\r\n"
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/middlewares/response_parser.rb:9:in `response_call'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/connection.rb:388:in `response'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/connection.rb:252:in `request'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/middlewares/idempotent.rb:27:in `error_call'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/middlewares/base.rb:11:in `error_call'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/middlewares/base.rb:11:in `error_call'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/connection.rb:272:in `rescue in request'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/connection.rb:214:in `request'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/middlewares/idempotent.rb:27:in `error_call'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/middlewares/base.rb:11:in `error_call'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/middlewares/base.rb:11:in `error_call'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/connection.rb:272:in `rescue in request'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/connection.rb:214:in `request'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/middlewares/idempotent.rb:27:in `error_call'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/middlewares/base.rb:11:in `error_call'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/middlewares/base.rb:11:in `error_call'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/connection.rb:272:in `rescue in request'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/excon-0.57.1/lib/excon/connection.rb:214:in `request'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/fog-core-1.44.3/lib/fog/core/connection.rb:83:in `request'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/fog-xml-0.1.3/lib/fog/xml/connection.rb:9:in `request'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/fog-aws-1.4.0/lib/fog/aws/storage.rb:613:in `_request'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/fog-aws-1.4.0/lib/fog/aws/storage.rb:607:in `request'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/fog-aws-1.4.0/lib/fog/aws/requests/storage/put_object.rb:48:in `put_object'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/fog-aws-1.4.0/lib/fog/aws/models/storage/file.rb:221:in `save'
        from /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/fog-core-1.44.3/lib/fog/core/collection.rb:50:in `create'

I've even tried hacking fog-core to insert the Content-Length header to no avail:

 def request(params, &block)
  params[:headers]['Content-Length'] = 45602    
  puts "requesting #{params[:headers]}"                                                                                                                                                            
  @excon.request(handle_path_prefix_for(params), &block)
end

/cc: @jgannondo


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4