Class: CarrierWave::Storage::AWSOptions

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

Constant Summary collapse

MULTIPART_THRESHOLD =
15 * 1024 * 1024
MULTIPART_TRESHOLD =

Backward compatibility

MULTIPART_THRESHOLD

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uploader) ⇒ AWSOptions

Returns a new instance of AWSOptions.



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

def initialize(uploader)
  @uploader = uploader
end

Instance Attribute Details

#uploader ⇒ Object (readonly)

Returns the value of attribute uploader.



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

def uploader
  @uploader
end

Instance Method Details

#expiration_options(options = {}) ⇒ Object



37
38
39
40
41
# File 'lib/carrierwave/storage/aws_options.rb', line 37

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



29
30
31
32
33
34
# File 'lib/carrierwave/storage/aws_options.rb', line 29

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

#read_options ⇒ Object



17
18
19
# File 'lib/carrierwave/storage/aws_options.rb', line 17

def read_options
  aws_read_options
end

#write_options(new_file) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/carrierwave/storage/aws_options.rb', line 21

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