class Paperclip::UriAdapter

Attributes

content_type[W]

Public Class Methods

new(target) click to toggle source
# File lib/paperclip/io_adapters/uri_adapter.rb, line 5
def initialize(target)
  @target = target
  @content = download_content
  cache_current_values
  @tempfile = copy_to_tempfile(@content)
end

Private Instance Methods

cache_current_values() click to toggle source
# File lib/paperclip/io_adapters/uri_adapter.rb, line 20
def cache_current_values
  @original_filename = @target.path.split("/").last
  @original_filename ||= "index.html"
  self.original_filename = @original_filename.strip

  @content_type = @content.content_type if @content.respond_to?(:content_type)
  @content_type ||= "text/html"

  @size = @content.size
end
copy_to_tempfile(src) click to toggle source
# File lib/paperclip/io_adapters/uri_adapter.rb, line 31
def copy_to_tempfile(src)
  while data = src.read(16*1024)
    destination.write(data)
  end
  src.close
  destination.rewind
  destination
end
download_content() click to toggle source
# File lib/paperclip/io_adapters/uri_adapter.rb, line 16
def download_content
  open(@target)
end