Sha256: ecddd0f901c2aa20ddba50d23c28e39643c6b4fb12dd970e9b63376cc9ad18a0

Contents?: true

Size: 641 Bytes

Versions: 4

Compression:

Stored size: 641 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.to_s.strip
      @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.3.1 lib/paperclip/io_adapters/uploaded_file_adapter.rb
paperclip-3.2.1 lib/paperclip/io_adapters/uploaded_file_adapter.rb
paperclip-3.3.0 lib/paperclip/io_adapters/uploaded_file_adapter.rb
paperclip-3.2.0 lib/paperclip/io_adapters/uploaded_file_adapter.rb