Class: CarrierWave::Storage::S3::File

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

Instance Method Summary collapse

Constructor Details

#initialize(path, identifier) ⇒ File

Returns a new instance of File.



48
49
50
51
# File 'lib/carrierwave/storage/s3.rb', line 48

def initialize(path, identifier)
  @path = path
  @identifier = identifier
end

Instance Method Details

#aboutObject



108
109
110
# File 'lib/carrierwave/storage/s3.rb', line 108

def about
  s3_object.about
end

#content_dispositionObject



124
125
126
# File 'lib/carrierwave/storage/s3.rb', line 124

def content_disposition
  s3_object.content_disposition
end

#content_disposition=(new_disposition) ⇒ Object



128
129
130
# File 'lib/carrierwave/storage/s3.rb', line 128

def content_disposition=(new_disposition)
  s3_object.content_disposition = new_disposition
end

#content_typeObject



116
117
118
# File 'lib/carrierwave/storage/s3.rb', line 116

def content_type
  s3_object.content_type
end

#content_type=(new_content_type) ⇒ Object



120
121
122
# File 'lib/carrierwave/storage/s3.rb', line 120

def content_type=(new_content_type)
  s3_object.content_type = new_content_type
end

#deleteObject

Remove the file from Amazon S3



89
90
91
# File 'lib/carrierwave/storage/s3.rb', line 89

def delete
  AWS::S3::S3Object.delete @path, bucket
end

#identifierObject

Returns the filename on S3

Returns

String

path to the file



71
72
73
# File 'lib/carrierwave/storage/s3.rb', line 71

def identifier
  @identifier
end

#metadataObject



112
113
114
# File 'lib/carrierwave/storage/s3.rb', line 112

def 
  s3_object.
end

#pathObject

Returns the current path of the file on S3

Returns

String

A path



60
61
62
# File 'lib/carrierwave/storage/s3.rb', line 60

def path
  @path
end

#readObject

Reads the contents of the file from S3

Returns

String

contents of the file



82
83
84
# File 'lib/carrierwave/storage/s3.rb', line 82

def read
  AWS::S3::S3Object.value @path, bucket
end

#s3_objectObject



136
137
138
# File 'lib/carrierwave/storage/s3.rb', line 136

def s3_object
  @s3_object ||= AWS::S3::S3Object.find(@path, bucket)
end

#storeObject



132
133
134
# File 'lib/carrierwave/storage/s3.rb', line 132

def store
  s3_object.store
end

#urlObject

Returns the url on Amazon’s S3 service

Returns

String

file’s url



100
101
102
103
104
105
106
# File 'lib/carrierwave/storage/s3.rb', line 100

def url
  if CarrierWave::config[:s3][:cnamed]
    ["http://", bucket, @path].compact.join('/')
  else
    ["http://s3.amazonaws.com", bucket, @path].compact.join('/')
  end
end