-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
If multipart is set on a 0-byte file to be uploaded to Fog, an invalid request is sent to the API:
Write a 2-byte file and upload with multipart:
f=File.open("testFile",'w+')
f.write(".")
=> 2
connection=Fog::Storage::AWS.new()
upFile=connection.directories.get("abucket").files.new(:key => "testFile", :body => f, :public=>false)
upFile.multipart_chunk_size=5242880
upFile.save
=> true
f.close
Now do the same with a 0 byte file:
f=File.open("testFile",'w+')
f.write("")
=> 0
upFile=connection.directories.get("abucket").files.new(:key => "testFile", :body => f, :public => false)
upFile.save
=> true
upFile.multipart_chunk_size=5242880
upFile.save
Excon::Error::BadRequest: Expected(200) <=> Actual(400 Bad Request)
excon.error.response
:body => "<Error><Code>MalformedXML</Code><Message>The XML you provided was not well-formed or did not validate against our published schema</Message><RequestId>XXX</RequestId><HostId>xxx</HostId></Error>"
:cookies => [
]
:headers => {
"Connection" => "close"
"Content-Type" => "application/xml"
"Date" => "Mon, 25 Jul 2016 10:20:03 GMT"
"Server" => "AmazonS3"
"x-amz-id-2" => "redacted"
"x-amz-request-id" => "redacted"
}
:host => "s3-x-y.amazonaws.com"
:local_address => "1.2.3.4"
:local_port => 52755
:path => "/abucket/testFile"
:port => 443
:reason_phrase => "Bad Request"
:remote_ip => "x.y.z.w"
:status => 400
:status_line => "HTTP/1.1 400 Bad Request\r\n"
from gems/ruby-2.1.10/gems/excon-0.51.0/lib/excon/middlewares/expects.rb:6:in `response_call'
from gems/ruby-2.1.10/gems/excon-0.51.0/lib/excon/middlewares/response_parser.rb:8:in `response_call'
from gems/ruby-2.1.10/gems/excon-0.51.0/lib/excon/connection.rb:389:in `response'
from ruby-2.1.10/gems/excon-0.51.0/lib/excon/connection.rb:253:in `request'
from gems/ruby-2.1.10/gems/fog-xml-0.1.2/lib/fog/xml/sax_parser_connection.rb:35:in `request'
from gems/ruby-2.1.10/gems/fog-xml-0.1.2/lib/fog/xml/connection.rb:7:in `request'
from gems/ruby-2.1.10/gems/fog-aws-0.9.4/lib/fog/aws/storage.rb:611:in `_request'
from ruby-2.1.10/gems/fog-aws-0.9.4/lib/fog/aws/storage.rb:606:in `request'
from ruby-2.1.10/gems/fog-aws-0.9.4/lib/fog/aws/requests/storage/complete_multipart_upload.rb:36:in `complete_multipart_upload'
from ruby-2.1.10/gems/fog-aws-0.9.4/lib/fog/aws/models/storage/file.rb:278:in `multipart_save'
from ruby-2.1.10/gems/fog-aws-0.9.4/lib/fog/aws/models/storage/file.rb:209:in `save'
The library allows non-multipart uploads of 0 byte files and multipart uploads of >=1 byte files, but fails on 0 byte multipart.
Metadata
Metadata
Assignees
Labels
No labels