Class: Aws::S3::MultipartFileUploader Private

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-sdk-resources/services/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: 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)
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)


27
28
29
30
# File 'lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb', line 27

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:

  • (Client)


33
34
35
# File 'lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb', line 33

def client
  @client
end

Instance Method Details

#upload(source, options = {}) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • source (String, Pathname, File, Tempfile)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :bucket (required, String)
  • :key (required, String)


39
40
41
42
43
44
45
46
47
# File 'lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb', line 39

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