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

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

15 * 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: {})

    a customizable set of options

Options Hash (options):

  • :client (Client)
  • :multipart_threshold (Integer)

    Files greater than ‘:multipart_threshold` bytes are uploaded using S3 multipart APIs.



13
14
15
16
17
# File 'lib/aws-sdk-s3/file_uploader.rb', line 13

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



20
21
22
# File 'lib/aws-sdk-s3/file_uploader.rb', line 20

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 this in bytes are uploaded using a MultipartFileUploader.

Returns:



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

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)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

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


30
31
32
33
34
35
36
# File 'lib/aws-sdk-s3/file_uploader.rb', line 30

def upload(source, options = {})
  if File.size(source) >= multipart_threshold
    MultipartFileUploader.new(@options).upload(source, options)
  else
    put_object(source, options)
  end
end