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
  @tempfile = copy_to_tempfile(@target)
end

Private Instance Methods

cache_current_values() click to toggle source
# File lib/paperclip/io_adapters/stringio_adapter.rb, line 13
def cache_current_values
  @original_filename = @target.original_filename if @target.respond_to?(:original_filename)
  @original_filename ||= "stringio.txt"
  @original_filename = @original_filename.strip

  @content_type = @target.content_type if @target.respond_to?(:content_type)
  @content_type ||= "text/plain"

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