Sha256: 467895aeb007bb718a49144adf6741e7b28ced3d1b983ce6e63bd4bfd12a0127

Contents?: true

Size: 630 Bytes

Versions: 4

Compression:

Stored size: 630 Bytes

Contents

module Paperclip
  class UploadedFileAdapter < AbstractAdapter
    def initialize(target)
      @target = target
      cache_current_values

      if @target.respond_to?(:tempfile)
        @tempfile = copy_to_tempfile(@target.tempfile)
      else
        @tempfile = copy_to_tempfile(@target)
      end
    end

    private

    def cache_current_values
      @original_filename = @target.original_filename
      @content_type = @target.content_type
      @size = File.size(@target.path)
    end
  end
end

Paperclip.io_adapters.register Paperclip::UploadedFileAdapter do |target|
  target.class.name.include?("UploadedFile")
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
paperclip-3.1.4 lib/paperclip/io_adapters/uploaded_file_adapter.rb
paperclip-3.1.2 lib/paperclip/io_adapters/uploaded_file_adapter.rb
paperclip-3.1.1 lib/paperclip/io_adapters/uploaded_file_adapter.rb
paperclip-3.1.0 lib/paperclip/io_adapters/uploaded_file_adapter.rb