Sha256: bdbf14eeaf0f376f43350033bf744be7af6060b9861054a7b691f30015bfb964

Contents?: true

Size: 686 Bytes

Versions: 14

Compression:

Stored size: 686 Bytes

Contents

module Paperclip
  class FileAdapter < AbstractAdapter
    def self.register
      Paperclip.io_adapters.register self do |target|
        File === target || ::Tempfile === target
      end
    end

    def initialize(target, options = {})
      super
      cache_current_values
    end

    private

    def cache_current_values
      self.original_filename = @target.original_filename if @target.respond_to?(:original_filename)
      self.original_filename ||= File.basename(@target.path)
      @tempfile = copy_to_tempfile(@target)
      @content_type = ContentTypeDetector.new(@target.path).detect
      @size = File.size(@target)
    end
  end
end

Paperclip::FileAdapter.register

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kt-paperclip-7.2.2 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-7.2.1 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-7.2.0 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-6.4.2 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-7.1.1 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-7.1.0 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-7.0.1 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-7.0.0 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-6.4.1 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-6.4.0 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-6.3.0 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-6.2.2 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-6.2.1 lib/paperclip/io_adapters/file_adapter.rb
kt-paperclip-6.2.0 lib/paperclip/io_adapters/file_adapter.rb