Module Paperclip::Storage::Fog
In: lib/paperclip/storage/fog.rb

fog is a modern and versatile cloud computing library for Ruby. Among others, it supports Amazon S3 to store your files. In contrast to the outdated AWS-S3 gem it is actively maintained and supports multiple locations. Amazon‘s S3 file hosting service is a scalable, easy place to store files for distribution. You can find out more about it at aws.amazon.com/s3 There are a few fog-specific options for has_attached_file, which will be explained using S3 as an example:

  • fog_credentials: Takes a Hash with your credentials. For S3, you can use the following format:
      aws_access_key_id: '<your aws_access_key_id>'
      aws_secret_access_key: '<your aws_secret_access_key>'
      provider: 'AWS'
      region: 'eu-west-1'
    
  • fog_directory: This is the name of the S3 bucket that will store your files. Remember that the bucket must be unique across all of Amazon S3. If the bucket does not exist, Paperclip will attempt to create it.
  • path: This is the key under the bucket in which the file will be stored. The URL will be constructed from the bucket and the path. This is what you will want to interpolate. Keys should be unique, like filenames, and despite the fact that S3 (strictly speaking) does not support directories, you can still use a / to separate parts of your file name.
  • fog_public: (optional, defaults to true) Should the uploaded files be public or not? (true/false)
  • fog_host: (optional) The fully-qualified domain name (FQDN) that is the alias to the S3 domain of your bucket, e.g. ‘images.example.com’. This can also be used in conjunction with Cloudfront (aws.amazon.com/cloudfront)

Methods

Constants

AWS_BUCKET_SUBDOMAIN_RESTRICTON_REGEX = /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/

Public Class methods

Public Instance methods

Returns representation of the data of the file assigned to the given style, in the format most representative of the current storage.

[Validate]