Sha256: 9d79c5741fd22e07067f58738912fe1710b1e377fdf69e1023ff86580ae4bc8a

Contents?: true

Size: 1.29 KB

Versions: 140

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Aws
  module S3
    class MultipartUpload

      alias_method :basic_complete, :complete

      # Completes the upload, requires a list of completed parts. You can
      # provide the list of parts with `:part_number` and `:etag` values.
      #
      #     upload.complete(multipart_upload: { parts: [
      #       { part_number: 1, etag:'etag1' },
      #       { part_number: 2, etag:'etag2' },
      #       ...
      #     ]})
      #
      # Alternatively, you can pass **`compute_parts: true`** and the part
      # list will be computed by calling {Client#list_parts}.
      #
      #     upload.complete(compute_parts: true)
      #
      # @option options [Boolean] :compute_parts (false) When `true`,
      #   the {Client#list_parts} method will be called to determine
      #   the list of required part numbers and their ETags.
      #
      def complete(options = {})
        if options.delete(:compute_parts)
          options[:multipart_upload] = { parts: compute_parts }
        end
        basic_complete(options)
      end

      private

      def compute_parts
        parts.sort_by(&:part_number).each.with_object([]) do |part, part_list|
          part_list << { part_number: part.part_number, etag: part.etag }
        end
      end

    end
  end
end

Version data entries

140 entries across 140 versions & 1 rubygems

Version Path
aws-sdk-s3-1.174.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.173.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.172.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.171.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.170.1 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.170.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.169.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.168.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.167.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.166.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.165.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.164.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.163.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.162.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.161.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.160.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.159.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.158.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.157.0 lib/aws-sdk-s3/customizations/multipart_upload.rb
aws-sdk-s3-1.156.0 lib/aws-sdk-s3/customizations/multipart_upload.rb