Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Docced it up for S3
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@223 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information
jyurek committed Sep 25, 2007
1 parent 66b4733 commit 9290b0e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
15 changes: 15 additions & 0 deletions lib/paperclip/paperclip.rb
Expand Up @@ -103,6 +103,21 @@ module ClassMethods
# URL, not relative to the +url_prefix+. This field is interpolated.
# has_attached_file :avatar, :missing_url => "/images/default_:style_avatar.png"
# User.new.avatar_url(:small) # => "/images/default_small_avatar.png"
# * +storage+: Paperclip has two ways of storing your files. The first is on the filesystem, as specified by
# the +path_prefix+ and +path+ parameters. The second is using Amazon's S3 service, via the AWS::S3 gem.
# When +storage+ is set to :s3, Paperclip will at :s3_credentials_file in its options for a path to a YAML
# file that will specify the access_key_id and secret_access_key for S3. If none is specified, it will look
# for a the same file at the default location of +RAILS_ROOT/config/s3.yml+. When using S3, the +url_prefix+
# is the name of the bucket in which the files will be stored. Note that while the +url_prefix+ is still
# interpolated, S3 does not allow anything but alphanumerics and underscores, so it's a good practice to keep
# your interpolations to the +path+ parameter. Files are stored with default permissions of :public_read. You
# can read more about AWS::S3 here[http://amazon.rubyforge.org/].
# Please note that S3 support is still experimental in Paperclip and does not have full test coverage. Use
# at your own risk.
# has_attached_file :avatar, :storage => :s3
# :url_prefix => "bucket",
# :path => ":attachment/:style/:id/:name"
# user.avatar_url # => "http://s3.amazonaws.com/bucket/avatars/original/13/me.png"
#
# == Interpolation
# The +path_prefix+, +url_prefix+, and +path+ options can have dynamic interpolation done so that the
Expand Down
6 changes: 3 additions & 3 deletions lib/paperclip/storage/filesystem.rb
@@ -1,6 +1,6 @@
module Thoughtbot
module Paperclip
module ClassMethods
module ClassMethods #:nodoc:

def has_attached_file_with_fs *attachment_names
has_attached_file_without_fs *attachment_names
Expand All @@ -9,8 +9,8 @@ def has_attached_file_with_fs *attachment_names

end

class Storage
class Filesystem < Storage
class Storage #:nodoc:
class Filesystem < Storage #:nodoc:
def path_for attachment, style = nil
style ||= attachment[:default_style]
file = attachment[:instance]["#{attachment[:name]}_file_name"]
Expand Down
6 changes: 3 additions & 3 deletions lib/paperclip/storage/s3.rb
@@ -1,6 +1,6 @@
module Thoughtbot
module Paperclip
module ClassMethods
module ClassMethods #:nodoc:
def has_attached_file_with_s3 *attachment_names
attachments, options = has_attached_file_without_s3 *attachment_names

Expand Down Expand Up @@ -35,8 +35,8 @@ def s3_credentials_file
end
end

class Storage
class S3 < Storage
class Storage #:nodoc:
class S3 < Storage #:nodoc:
def path_for attachment, style = nil
style ||= attachment[:default_style]
file = attachment[:instance]["#{attachment[:name]}_file_name"]
Expand Down

0 comments on commit 9290b0e

Please sign in to comment.