Class: CarrierWave::Storage::AWSOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/carrierwave/storage/aws_options.rb

Constant Summary collapse

MULTIPART_TRESHOLD =
15 * 1024 * 1024

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uploader) ⇒ AWSOptions

Returns a new instance of AWSOptions.


10
11
12
# File 'lib/carrierwave/storage/aws_options.rb', line 10

def initialize(uploader)
  @uploader = uploader
end

Instance Attribute Details

#uploaderObject (readonly)

Returns the value of attribute uploader


8
9
10
# File 'lib/carrierwave/storage/aws_options.rb', line 8

def uploader
  @uploader
end

Instance Method Details

#expiration_options(options = {}) ⇒ Object


34
35
36
37
38
# File 'lib/carrierwave/storage/aws_options.rb', line 34

def expiration_options(options = {})
  uploader_expiration = uploader.aws_authenticated_url_expiration

  { expires_in: uploader_expiration }.merge(options)
end

#move_options(file) ⇒ Object Also known as: copy_options


26
27
28
29
30
31
# File 'lib/carrierwave/storage/aws_options.rb', line 26

def move_options(file)
  {
    acl: uploader.aws_acl,
    multipart_copy: file.size >= MULTIPART_TRESHOLD
  }.merge(aws_attributes).merge(aws_write_options)
end

#read_optionsObject


14
15
16
# File 'lib/carrierwave/storage/aws_options.rb', line 14

def read_options
  aws_read_options
end

#write_options(new_file) ⇒ Object


18
19
20
21
22
23
24
# File 'lib/carrierwave/storage/aws_options.rb', line 18

def write_options(new_file)
  {
    acl: uploader.aws_acl,
    body: new_file.to_file,
    content_type: new_file.content_type
  }.merge(aws_attributes).merge(aws_write_options)
end