Represents uploads in progress for a single object.
@example Cancel all uploads for an object
object.multipart_uploads.each(&:abort)
@example Get an upload by ID
object.multipart_uploads[id]
@return [S3Object] The object to which the uploads belong.
@private
# File lib/aws/s3/object_upload_collection.rb, line 33 def initialize(object, opts = {}) @all_uploads = MultipartUploadCollection.new(object.bucket). with_prefix(object.key) @object = object super end
@return [MultipartUpload] An object representing the upload
with the given ID.
@param [String] id The ID of an upload to get.
# File lib/aws/s3/object_upload_collection.rb, line 70 def [] id MultipartUpload.new(object, id) end
Creates a new multipart upload. It is usually more convenient to use {AWS::S3::S3Object#multipart_upload}.
# File lib/aws/s3/object_upload_collection.rb, line 43 def create(options = {}) options[:storage_class] = :reduced_redundancy if options.delete(:reduced_redundancy) initiate_opts = { :bucket_name => object.bucket.name, :key => object.key }.merge(options) id = client.initiate_multipart_upload(initiate_opts).upload_id MultipartUpload.new(object, id) end
Iterates the uploads in the collection.
@yieldparam [MultipartUpload] upload An upload in the
collection.
@return [nil]
# File lib/aws/s3/object_upload_collection.rb, line 59 def each(options = {}, &block) @all_uploads.each(options) do |upload| yield(upload) if upload.object.key == @object.key end nil end