Class: Aws::S3::FileUploader Private

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

Constant Summary collapse

ONE_HUNDRED_MEGABYTES =

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.

100 * 1024 * 1024

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FileUploader

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

Parameters:

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

Options Hash (options):

  • :client (Client)
  • :multipart_threshold (Integer) — default: 104857600


15
16
17
18
19
20
# File 'lib/aws-sdk-s3/file_uploader.rb', line 15

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



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

def client
  @client
end

#multipart_thresholdInteger (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 Files larger than or equal to this in bytes are uploaded using a MultipartFileUploader.

Returns:



27
28
29
# File 'lib/aws-sdk-s3/file_uploader.rb', line 27

def multipart_threshold
  @multipart_threshold
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)

    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]

  • :thread_count (Integer)

    The thread count to use for multipart uploads. Ignored for objects smaller than the multipart threshold.



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/aws-sdk-s3/file_uploader.rb', line 39

def upload(source, options = {})
  Aws::Plugins::UserAgent.metric('S3_TRANSFER') do
    if File.size(source) >= multipart_threshold
      MultipartFileUploader.new(@options).upload(source, options)
    else
      # remove multipart parameters not supported by put_object
      options.delete(:thread_count)
      put_object(source, options)
    end
  end
end