Class: CarrierWave::Uploader::Download::RemoteFile
- Inherits:
-
Object
- Object
- CarrierWave::Uploader::Download::RemoteFile
show all
- Defined in:
- lib/carrierwave/uploader/download.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(uri, remote_headers = {}, skip_ssrf_protection: false) ⇒ RemoteFile
Returns a new instance of RemoteFile.
16
17
18
19
20
21
|
# File 'lib/carrierwave/uploader/download.rb', line 16
def initialize(uri, = {}, skip_ssrf_protection: false)
@uri = uri
@remote_headers = .reverse_merge('User-Agent' => "CarrierWave/#{CarrierWave::VERSION}")
@file, @content_type, @headers = nil
@skip_ssrf_protection = skip_ssrf_protection
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
87
88
89
|
# File 'lib/carrierwave/uploader/download.rb', line 87
def method_missing(*args, &block)
file.send(*args, &block)
end
|
Instance Attribute Details
#uri ⇒ Object
Returns the value of attribute uri.
14
15
16
|
# File 'lib/carrierwave/uploader/download.rb', line 14
def uri
@uri
end
|
Instance Method Details
#content_type ⇒ Object
40
41
42
|
# File 'lib/carrierwave/uploader/download.rb', line 40
def content_type
@content_type || 'application/octet-stream'
end
|
44
45
46
|
# File 'lib/carrierwave/uploader/download.rb', line 44
def
@headers || {}
end
|
#http? ⇒ Boolean
36
37
38
|
# File 'lib/carrierwave/uploader/download.rb', line 36
def http?
@uri.scheme =~ /^https?$/
end
|
#original_filename ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/carrierwave/uploader/download.rb', line 23
def original_filename
filename = || filename_from_uri
mime_type = MIME::Types[content_type].first
unless File.extname(filename).present? || mime_type.blank?
filename = "#{filename}.#{mime_type.extensions.first}"
end
filename
end
|
#respond_to?(*args) ⇒ Boolean
32
33
34
|
# File 'lib/carrierwave/uploader/download.rb', line 32
def respond_to?(*args)
super or file.respond_to?(*args)
end
|