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

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)


18
19
20
# File 'lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb', line 18

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


23
24
25
# File 'lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb', line 23

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 (requried, String)
  • :key (requried, String)


29
30
31
32
33
34
35
36
37
# File 'lib/aws-sdk-resources/services/s3/multipart_file_uploader.rb', line 29

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