class AWS::S3::UploadedPart

Represents a part of a multipart upload that has been uploaded to S3.

@example Get the total size of the uploaded parts

upload.parts.inject(0) { |sum, part| sum + part.size }

Attributes

part_number[R]

@return [Integer] The part number.

upload[R]

@return [MultipartUpload] The upload to which this belongs.

Public Class Methods

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

@api private

Calls superclass method AWS::Core::Model.new
# File lib/aws/s3/uploaded_part.rb, line 33
def initialize(upload, part_number, opts = {})
  @upload = upload
  @part_number = part_number
  @etag = opts[:etag]
  super
end

Public Instance Methods

==(other) click to toggle source
# File lib/aws/s3/uploaded_part.rb, line 40
def ==(other)
  other.kind_of?(UploadedPart) and
    other.upload == upload and
    other.part_number == part_number
end
Also aliased as: eql?
eql?(other)
Alias for: ==
etag() click to toggle source

@return [String] The ETag of the part.

# File lib/aws/s3/uploaded_part.rb, line 60
def etag
  @etag ||= get_attribute(:etag)
  @etag
end
last_modified() click to toggle source

@return [DateTime] The time at which the part was last

modified.
# File lib/aws/s3/uploaded_part.rb, line 55
def last_modified
  get_attribute(:last_modified)
end
size() click to toggle source

@return [Integer] The size of the part as it currently

exists in S3.
# File lib/aws/s3/uploaded_part.rb, line 49
def size
  get_attribute(:size)
end

Private Instance Methods

get_attribute(name) click to toggle source

@api private

# File lib/aws/s3/uploaded_part.rb, line 67
def get_attribute(name)
  (resp = client.list_parts(:bucket_name => upload.object.bucket.name,
                            :key => upload.object.key,
                            :upload_id => upload.id,
                            :part_number_marker => part_number-1,
                            :max_parts => 1) and
   part = resp.parts.first and
   part.part_number == part_number and
   part.send(name)) or
    raise "part 3 of upload abc123 does not exist"
end