Class: FileUploader::HTTPResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/resource/resource_http.rb

Constant Summary

Constants included from S3Resource

S3Resource::S3_BUCKET, S3Resource::S3_CONFIG, S3Resource::S3_KEY, S3Resource::S3_SECRET

Instance Attribute Summary

Attributes inherited from Resource

#tempfile

Instance Method Summary collapse

Methods inherited from Resource

create, #destroy, #extension, #mime_type, #uri

Methods included from S3Resource

#destroy_s3, #send

Constructor Details

#initialize(resource) ⇒ HTTPResource

Returns a new instance of HTTPResource.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/resource/resource_http.rb', line 5

def initialize(resource)
  super

  status, file = Net::HTTP.get_response(URI.parse(self.uri))

  File.open(self.basename, 'wb') do |open_file|
    open_file.print(file)
  end

  self.tempfile = File.open(self.basename)
end

Instance Method Details

#basenameObject



17
18
19
# File 'lib/resource/resource_http.rb', line 17

def basename
  File.basename(self.uri)
end

#pathObject



21
22
23
# File 'lib/resource/resource_http.rb', line 21

def path
  File.realdirpath(self.tempfile)
end