class AWS::S3::ObjectUploadCollection

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]

Attributes

object[R]

@return [S3Object] The object to which the uploads belong.

Public Class Methods

new(object, opts = {}) click to toggle source

@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

Public Instance Methods

[](id) click to toggle source

@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
create(options = {}) click to toggle source

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
each(options = {}) { |upload| ... } click to toggle source

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