Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
aa6338a9
Commit
aa6338a9
authored
Jan 19, 2013
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
:s3_host_name can be a proc
parent
29bb5643
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletions
+24
-1
lib/paperclip/storage/s3.rb
+4
-1
test/storage/s3_test.rb
+20
-0
No files found.
lib/paperclip/storage/s3.rb
View file @
aa6338a9
...
...
@@ -172,7 +172,10 @@ module Paperclip
end
def
s3_host_name
@options
[
:s3_host_name
]
||
s3_credentials
[
:s3_host_name
]
||
"s3.amazonaws.com"
host_name
=
@options
[
:s3_host_name
]
host_name
=
host_name
.
call
(
self
)
if
host_name
.
is_a?
(
Proc
)
host_name
||
s3_credentials
[
:s3_host_name
]
||
"s3.amazonaws.com"
end
def
s3_host_alias
...
...
test/storage/s3_test.rb
View file @
aa6338a9
...
...
@@ -238,6 +238,26 @@ class S3Test < Test::Unit::TestCase
end
end
context
"dynamic s3_host_name"
do
setup
do
rebuild_model
:storage
=>
:s3
,
:s3_credentials
=>
{},
:bucket
=>
"bucket"
,
:path
=>
":attachment/:basename.:extension"
,
:s3_host_name
=>
lambda
{
|
a
|
a
.
instance
.
value
}
@dummy
=
Dummy
.
new
class
<<
@dummy
attr_accessor
:value
end
@dummy
.
avatar
=
StringIO
.
new
(
"."
)
end
should
"use s3_host_name as a proc if available"
do
@dummy
.
value
=
"s3.something.com"
assert_equal
"http://s3.something.com/bucket/avatars/stringio.txt"
,
@dummy
.
avatar
.
url
(
:original
,
:timestamp
=>
false
)
end
end
context
"An attachment that uses S3 for storage and has styles that return different file types"
do
setup
do
rebuild_model
:styles
=>
{
:large
=>
[
'500x500#'
,
:jpg
]
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment