Sha256: 9eb1df000db5cf864f77c3e52a6b032e38f0ac868c84c8464cfb354fbd743c79

Contents?: true

Size: 1.59 KB

Versions: 60

Compression:

Stored size: 1.59 KB

Contents

# encoding: utf-8

module CarrierWave
  module Storage

    ##
    # File storage stores file to the Filesystem (surprising, no?). There's really not much
    # to it, it uses the store_dir defined on the uploader as the storage location. That's
    # pretty much it.
    #
    class File < Abstract

      ##
      # Move the file to the uploader's store path.
      #
      # By default, store!() uses copy_to(), which operates by copying the file
      # from the cache to the store, then deleting the file from the cache.
      # If move_to_store() is overriden to return true, then store!() uses move_to(),
      # which simply moves the file from cache to store.  Useful for large files.
      #
      # === Parameters
      #
      # [file (CarrierWave::SanitizedFile)] the file to store
      #
      # === Returns
      #
      # [CarrierWave::SanitizedFile] a sanitized file
      #
      def store!(file)
        path = ::File.expand_path(uploader.store_path, uploader.root)
        if uploader.move_to_store
          file.move_to(path, uploader.permissions)
        else
          file.copy_to(path, uploader.permissions)
        end
      end

      ##
      # Retrieve the file from its store path
      #
      # === Parameters
      #
      # [identifier (String)] the filename of the file
      #
      # === Returns
      #
      # [CarrierWave::SanitizedFile] a sanitized file
      #
      def retrieve!(identifier)
        path = ::File.expand_path(uploader.store_path(identifier), uploader.root)
        CarrierWave::SanitizedFile.new(path)
      end

    end # File
  end # Storage
end # CarrierWave

Version data entries

60 entries across 55 versions & 4 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.7.4 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.7.3 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.7.2 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.7.1 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.7.0 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.6.9 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.6.8 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.6.7 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.6.6 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.6.5 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.6.4 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.6.3 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.6.2 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.6.1 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.6.0 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.5.17 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.5.16 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.5.15 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb
classiccms-0.5.14 vendor/bundle/gems/carrierwave-0.6.2/lib/carrierwave/storage/file.rb