Sha256: 39e10a8015b7f55a08ec8dace1c906a82d2b232812a6c94ebbfc63c5dc1291cd

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 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.
      #
      # === 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)
        file.move_to(path, uploader.permissions)
        file
      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

      def rename!(file)
        path = ::File.expand_path(uploader.store_path, uploader.root)
        file.move_to(path, uploader.permissions)
        file
      end

    end # File
  end # Storage
end # CarrierWave

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locomotive_carrierwave-0.5.0.1.beta3 lib/carrierwave/storage/file.rb
locomotive_carrierwave-0.5.0.1.beta2 lib/carrierwave/storage/file.rb
locomotive_carrierwave-0.5.0.1.beta1 lib/carrierwave/storage/file.rb
locomotive_carrierwave-0.5.0.1 lib/carrierwave/storage/file.rb