Sha256: 40542160a390e9e989a4a24170bd337f97cd1e96f7edbb83a7be5e3a8b214531
Contents?: true
Size: 781 Bytes
Versions: 26
Compression:
Stored size: 781 Bytes
Contents
module Paperclip class StringioAdapter < AbstractAdapter def initialize(target) @target = target cache_current_values end attr_writer :content_type private 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 def copy_to_tempfile(source) while data = source.read(16*1024) destination.write(data) end destination.rewind destination end end end Paperclip.io_adapters.register Paperclip::StringioAdapter do |target| StringIO === target end
Version data entries
26 entries across 24 versions & 6 rubygems