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
b8aee5f7
Commit
b8aee5f7
authored
Jul 28, 2010
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
S3 features passing and basic attempt to separate s3-implementation-specific methods
parent
85c65d3d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
3 deletions
+46
-3
features/s3.feature
+10
-2
features/step_definitions/s3_steps.rb
+9
-0
features/support/s3.rb
+25
-0
lib/paperclip/storage.rb
+2
-1
No files found.
features/s3.feature
View file @
b8aee5f7
...
@@ -7,13 +7,21 @@ Feature: Running paperclip in a Rails app using basic S3 support
...
@@ -7,13 +7,21 @@ Feature: Running paperclip in a Rails app using basic S3 support
class User < ActiveRecord::Base
class User < ActiveRecord::Base
has_attached_file :avatar,
has_attached_file :avatar,
:storage => :s3,
:storage => :s3,
:path => "/:attachment/:id/:style/:filename",
:s3_credentials => Rails.root.join("config/s3.yml")
:s3_credentials => Rails.root.join("config/s3.yml")
end
end
"""
"""
And
I validate my S3 credentials
And
I save the following as
"config/s3.yml"
"""
bucket: <%= ENV['PAPERCLIP_TEST_BUCKET'] || 'paperclip' %>
access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
"""
When
I visit /users/new
When
I visit /users/new
And
I fill in
"user_name"
with
"something"
And
I fill in
"user_name"
with
"something"
And
I attach the file
"test/fixtures/5k.png"
to
"user_avatar"
And
I attach the file
"test/fixtures/5k.png"
to
"user_avatar"
And
I press
"Submit"
And
I press
"Submit"
Then I should see "Name
:
something"
Then I should see "Name
:
something"
And I should see an image with a path of "http
:
//s3.amazonaws.com/paperclip/
system/
avatars/1/original/5k.png"
And I should see an image with a path of "http
:
//s3.amazonaws.com/paperclip/avatars/1/original/5k.png"
And the file at "http
:
//s3.amazonaws.com/paperclip/
system/
avatars/1/original/5k.png"
is
the
same
as
"test/fixtures/5k.png"
And the file at "http
:
//s3.amazonaws.com/paperclip/avatars/1/original/5k.png"
is
the
same
as
"test/fixtures/5k.png"
features/step_definitions/s3_steps.rb
0 → 100644
View file @
b8aee5f7
Given
/I validate my S3 credentials/
do
key
=
ENV
[
'AWS_ACCESS_KEY_ID'
]
secret
=
ENV
[
'AWS_SECRET_ACCESS_KEY'
]
key
.
should_not
be_nil
secret
.
should_not
be_nil
assert_credentials
(
key
,
secret
)
end
features/support/s3.rb
0 → 100644
View file @
b8aee5f7
module
AWSS3Methods
def
load_s3
begin
require
'aws/s3'
rescue
LoadError
=>
e
fail
"You do not have aws-s3 installed."
end
end
def
assert_credentials
(
key
,
secret
)
load_s3
begin
AWS
::
S3
::
Base
.
establish_connection!
(
:access_key_id
=>
key
,
:secret_access_key
=>
secret
)
AWS
::
S3
::
Service
.
buckets
rescue
AWS
::
S3
::
ResponseError
=>
e
fail
"Could not connect using AWS credentials in AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. "
+
"Please make sure these are set in your environment."
end
end
end
World
(
AWSS3Methods
)
lib/paperclip/storage.rb
View file @
b8aee5f7
...
@@ -144,7 +144,8 @@ module Paperclip
...
@@ -144,7 +144,8 @@ module Paperclip
@s3_headers
=
@options
[
:s3_headers
]
||
{}
@s3_headers
=
@options
[
:s3_headers
]
||
{}
@s3_host_alias
=
@options
[
:s3_host_alias
]
@s3_host_alias
=
@options
[
:s3_host_alias
]
unless
@url
.
to_s
.
match
(
/^:s3.*url$/
)
unless
@url
.
to_s
.
match
(
/^:s3.*url$/
)
@url
=
":s3_path_url"
@path
=
@path
.
gsub
(
/:url/
,
@url
)
@url
=
":s3_path_url"
end
end
AWS
::
S3
::
Base
.
establish_connection!
(
@s3_options
.
merge
(
AWS
::
S3
::
Base
.
establish_connection!
(
@s3_options
.
merge
(
:access_key_id
=>
@s3_credentials
[
:access_key_id
],
:access_key_id
=>
@s3_credentials
[
:access_key_id
],
...
...
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