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
d6ebd321
Commit
d6ebd321
authored
Sep 08, 2009
by
Tristan Dunn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run S3 configuration file through ERB before parsing the YAML.
parent
836f44e6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
2 deletions
+30
-2
lib/paperclip.rb
+1
-0
lib/paperclip/storage.rb
+2
-2
test/fixtures/s3.yml
+4
-0
test/storage_test.rb
+23
-0
No files found.
lib/paperclip.rb
View file @
d6ebd321
...
...
@@ -25,6 +25,7 @@
#
# See the +has_attached_file+ documentation for more details.
require
'erb'
require
'tempfile'
require
'paperclip/upfile'
require
'paperclip/iostream'
...
...
lib/paperclip/storage.rb
View file @
d6ebd321
...
...
@@ -227,9 +227,9 @@ module Paperclip
def
find_credentials
creds
case
creds
when
File
YAML
.
load_file
(
creds
.
path
)
YAML
::
load
(
ERB
.
new
(
File
.
read
(
creds
.
path
)).
result
)
when
String
YAML
.
load_file
(
creds
)
YAML
::
load
(
ERB
.
new
(
File
.
read
(
creds
)).
result
)
when
Hash
creds
else
...
...
test/fixtures/s3.yml
View file @
d6ebd321
...
...
@@ -2,3 +2,7 @@ development:
key
:
54321
production
:
key
:
12345
test
:
bucket
:
<%= ENV['S3_BUCKET'] %>
access_key_id
:
<%= ENV['S3_KEY'] %>
secret_access_key
:
<%= ENV['S3_SECRET'] %>
test/storage_test.rb
View file @
d6ebd321
...
...
@@ -236,6 +236,29 @@ class StorageTest < Test::Unit::TestCase
end
end
context
"with S3 credentials in a YAML file"
do
setup
do
ENV
[
'S3_KEY'
]
=
'env_key'
ENV
[
'S3_BUCKET'
]
=
'env_bucket'
ENV
[
'S3_SECRET'
]
=
'env_secret'
rails_env
(
'test'
)
rebuild_model
:storage
=>
:s3
,
:s3_credentials
=>
File
.
new
(
File
.
join
(
File
.
dirname
(
__FILE__
),
"fixtures/s3.yml"
))
Dummy
.
delete_all
@dummy
=
Dummy
.
new
end
should
"run it the file through ERB"
do
assert_equal
'env_bucket'
,
@dummy
.
avatar
.
bucket_name
assert_equal
'env_key'
,
AWS
::
S3
::
Base
.
connection
.
options
[
:access_key_id
]
assert_equal
'env_secret'
,
AWS
::
S3
::
Base
.
connection
.
options
[
:secret_access_key
]
end
end
unless
ENV
[
"S3_TEST_BUCKET"
].
blank?
context
"Using S3 for real, an attachment with S3 storage"
do
setup
do
...
...
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