class Paperclip::StringioAdapter

Attributes

content_type[W]

Public Class Methods

new(target) click to toggle source
# File lib/paperclip/io_adapters/stringio_adapter.rb, line 3
def initialize(target)
  @target = target
  cache_current_values
end

Private Instance Methods

cache_current_values() click to toggle source
# File lib/paperclip/io_adapters/stringio_adapter.rb, line 12
def cache_current_values
  self.original_filename = @target.original_filename if @target.respond_to?(:original_filename)
  self.original_filename ||= "data"
  @tempfile = copy_to_tempfile(@target)
  @content_type = ContentTypeDetector.new(@tempfile.path).detect
  @size = @target.size
end
copy_to_tempfile(source) click to toggle source
# File lib/paperclip/io_adapters/stringio_adapter.rb, line 20
def copy_to_tempfile(source)
  while data = source.read(16*1024)
    destination.write(data)
  end
  destination.rewind
  destination
end