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 }
@return [Integer] The part number.
@return [MultipartUpload] The upload to which this belongs.
@api private
# 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
# 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
@return [String] The ETag of the part.
# File lib/aws/s3/uploaded_part.rb, line 60 def etag @etag ||= get_attribute(:etag) @etag end
@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
@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
@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 #{part_number} of upload #{upload.id} does not exist" end