1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/requests/storage/initiate_multipart_upload.rb
Jonas Pfenniger f6d361b2e2 AWS | storage: big refactor
Logics have been centralised:

* region to hostname
* url generation
* signature
* chaning scheme also changes the port

During the process a couple of inconsistencies have also
been fixed.

Known limitations:

When using the @endpoint with a custom port you need to specify the port
when using get_object_http_url or get_object_https_url.

When using bucket names that contain dots outside of us-east-1 make sure to
access it with the same region in your AWS::Storage.
2013-04-16 23:30:35 +01:00

44 lines
2 KiB
Ruby

module Fog
module Storage
class AWS
class Real
require 'fog/aws/parsers/storage/initiate_multipart_upload'
# Initiate a multipart upload to an S3 bucket
#
# @param bucket_name [String] Name of bucket to create object in
# @param object_name [String] Name of object to create
# @param options [Hash]:
# @option options [String] Cache-Control Caching behaviour
# @option options [String] Content-Disposition Presentational information for the object
# @option options [String] Content-Encoding Encoding of object data
# @option options [String] Content-MD5 Base64 encoded 128-bit MD5 digest of message (defaults to Base64 encoded MD5 of object.read)
# @option options [String] Content-Type Standard MIME type describing contents (defaults to MIME::Types.of.first)
# @option options [String] x-amz-acl Permissions, must be in ['private', 'public-read', 'public-read-write', 'authenticated-read']
# @option options [String] x-amz-meta-#{name} Headers to be returned with object, note total size of request without body must be less than 8 KB.
#
# @return [Excon::Response] response:
# * body [Hash]:
# * Bucket [String] - Bucket where upload was initiated
# * Key [String] - Object key where the upload was initiated
# * UploadId [String] - Id for initiated multipart upload
#
# @see http://docs.amazonwebservices.com/AmazonS3/latest/API/mpUploadInitiate.html
#
def initiate_multipart_upload(bucket_name, object_name, options = {})
request({
:expects => 200,
:headers => options,
:bucket_name => bucket_name,
:object_name => object_name,
:method => 'POST',
:parser => Fog::Parsers::Storage::AWS::InitiateMultipartUpload.new,
:query => {'uploads' => nil}
})
end
end # Real
end # Storage
end # AWS
end # Fog