Class: AWS::S3::ObjectUploadCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/aws/s3/object_upload_collection.rb

Overview

Represents uploads in progress for a single object.

Examples:

Cancel all uploads for an object

object.multipart_uploads.each(&:abort)

Get an upload by ID

object.multipart_uploads[id]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#objectS3Object (readonly)

Returns The object to which the uploads belong.

Returns:

  • (S3Object)

    The object to which the uploads belong.



36
37
38
# File 'lib/aws/s3/object_upload_collection.rb', line 36

def object
  @object
end

Instance Method Details

#[](id) ⇒ MultipartUpload

Returns An object representing the upload with the given ID.

Parameters:

  • id (String)

    The ID of an upload to get.

Returns:

  • (MultipartUpload)

    An object representing the upload with the given ID.



76
77
78
# File 'lib/aws/s3/object_upload_collection.rb', line 76

def [] id
  MultipartUpload.new(object, id)
end

#create(options = {}) ⇒ Object

Creates a new multipart upload. It is usually more convenient to use S3Object#multipart_upload.



49
50
51
52
53
54
55
56
57
58
# File 'lib/aws/s3/object_upload_collection.rb', line 49

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| ... } ⇒ nil

Iterates the uploads in the collection.

Yield Parameters:

Returns:

  • (nil)


65
66
67
68
69
70
# File 'lib/aws/s3/object_upload_collection.rb', line 65

def each(options = {}, &block)
  @all_uploads.each(options) do |upload|
    yield(upload) if upload.object.key == @object.key
  end
  nil
end