Class: Aws::S3::MultipartFileUploader Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-s3/multipart_file_uploader.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: MultipartProgress, PartList

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.

5MB

5 * 1024 * 1024
FILE_TOO_SMALL =

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.

"unable to multipart upload files smaller than 5MB"
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.

10_000
THREAD_COUNT =

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.

10
CREATE_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.

Set.new(
  Client.api.operation(:create_multipart_upload).input.shape.member_names
)
COMPLETE_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.

Set.new(
  Client.api.operation(:complete_multipart_upload).input.shape.member_names
)
UPLOAD_PART_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.

Set.new(
  Client.api.operation(:upload_part).input.shape.member_names
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ MultipartFileUploader

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 MultipartFileUploader.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :client (Client)
  • :thread_count (Integer) — default: THREAD_COUNT


35
36
37
38
# File 'lib/aws-sdk-s3/multipart_file_uploader.rb', line 35

def initialize(options = {})
  @client = options[:client] || Client.new
  @thread_count = options[:thread_count] || THREAD_COUNT
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:



41
42
43
# File 'lib/aws-sdk-s3/multipart_file_uploader.rb', line 41

def client
  @client
end

Instance Method Details

#upload(source, options = {}) ⇒ Seahorse::Client::Response

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 - the CompleteMultipartUploadResponse.

Parameters:

  • source (String, Pathname, File, Tempfile)

    The file to upload.

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

    a customizable set of options

Options Hash (options):

  • :bucket (required, String)

    The bucket to upload to.

  • :key (required, String)

    The key for the object.

  • :progress_callback (Proc)

    A Proc that will be called when each chunk of the upload is sent. It will be invoked with [bytes_read], [total_sizes]

Returns:

  • (Seahorse::Client::Response)
    • the CompleteMultipartUploadResponse



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

def upload(source, options = {})
  if File.size(source) < MIN_PART_SIZE
    raise ArgumentError, FILE_TOO_SMALL
  else
    upload_id = initiate_upload(options)
    parts = upload_parts(upload_id, source, options)
    complete_upload(upload_id, parts, options)
  end
end