Class: Aws::S3::ObjectMultipartCopier Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-s3/object_multipart_copier.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: PartQueue

Constant Summary collapse

MIN_PART_SIZE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

rubocop:disable Metrics/ClassLength

5 * 1024 * 1024
MAX_PARTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

5MB

10_000
API_OPTIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  create_multipart_upload: Set.new(Client.api.operation(:create_multipart_upload).input.shape.member_names),
  upload_part_copy: Set.new(Client.api.operation(:upload_part_copy).input.shape.member_names),
  complete_multipart_upload: Set.new(Client.api.operation(:complete_multipart_upload).input.shape.member_names)
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ObjectMultipartCopier

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ObjectMultipartCopier.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :client (Client)
  • :min_part_size (Integer) — default: 52428800

    Size of copied parts. Defaults to 50MB.

  • :thread_count (Integer) — default: 10

    Number of concurrent threads to use for copying parts.

  • :use_source_parts (Boolean) — default: false

    Use part sizes defined on the source object if any exist. If copying or moving an object that is already multipart, this does not re-part the object, instead re-using the part definitions on the original. That means the etag and any checksums will not change. This is especially useful if the source object has parts with varied sizes.



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/aws-sdk-s3/object_multipart_copier.rb', line 31

def initialize(options = {})
  @use_source_parts = options.delete(:use_source_parts) || false
  @thread_count = options.delete(:thread_count) || 10
  @min_part_size = options.delete(:min_part_size) || (MIN_PART_SIZE * 10)
  @client = options[:client] || Client.new
  @source_client = nil
  @source = nil
  @source_etag = nil
  @source_parts_count = nil
  @first_part_size = nil
end

Instance Attribute Details

#clientClient (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:



44
45
46
# File 'lib/aws-sdk-s3/object_multipart_copier.rb', line 44

def client
  @client
end

Instance Method Details

#copy(options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/aws-sdk-s3/object_multipart_copier.rb', line 47

def copy(options = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  @source_client = options[:copy_source_client] || @client
  @source = resolve_source(options[:copy_source])
   = (options)
  size = [:content_length]
  @source_etag = [:etag]
  @source[:version_id] ||= [:version_id]
  resolve_source_parts
  tag_set = resolve_tags(options)
  annotations = resolve_annotations(options)

  create_opts = resolve_create_opts(, options)
  options[:upload_id] = initiate_upload(create_opts)

  begin
    parts = copy_parts(size, default_part_size(size), options)
    resp = complete_upload(parts, options)
  rescue StandardError => e
    abort_upload(options)
    raise e
  end

  put_tags(tag_set, resp, options) if tag_set
  put_annotations(annotations, resp, options) if annotations&.any?
end