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
435ecba0
Commit
435ecba0
authored
Apr 08, 2011
by
Mike Breen
Committed by
Chad Pytel
Apr 08, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expiring_url should set the :use_ssl flag when calling S3Object.url_for
parent
7003961d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
lib/paperclip/storage/s3.rb
+1
-1
test/storage_test.rb
+29
-1
No files found.
lib/paperclip/storage/s3.rb
View file @
435ecba0
...
...
@@ -95,7 +95,7 @@ module Paperclip
end
def
expiring_url
(
time
=
3600
)
AWS
::
S3
::
S3Object
.
url_for
(
path
,
bucket_name
,
:expires_in
=>
time
)
AWS
::
S3
::
S3Object
.
url_for
(
path
,
bucket_name
,
:expires_in
=>
time
,
:use_ssl
=>
(
s3_protocol
==
'https'
)
)
end
def
bucket_name
...
...
test/storage_test.rb
View file @
435ecba0
...
...
@@ -114,6 +114,34 @@ class StorageTest < Test::Unit::TestCase
end
end
context
"Generating a secure url with an expiration"
do
setup
do
AWS
::
S3
::
Base
.
stubs
(
:establish_connection!
)
rebuild_model
:storage
=>
:s3
,
:s3_credentials
=>
{
:production
=>
{
:bucket
=>
"prod_bucket"
},
:development
=>
{
:bucket
=>
"dev_bucket"
}
},
:s3_host_alias
=>
"something.something.com"
,
:s3_permissions
=>
"private"
,
:path
=>
":attachment/:basename.:extension"
,
:url
=>
":s3_alias_url"
rails_env
(
"production"
)
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
StringIO
.
new
(
"."
)
AWS
::
S3
::
S3Object
.
expects
(
:url_for
).
with
(
"avatars/stringio.txt"
,
"prod_bucket"
,
{
:expires_in
=>
3600
,
:use_ssl
=>
true
})
@dummy
.
avatar
.
expiring_url
end
should
"should succeed"
do
assert
true
end
end
context
"Generating a url with an expiration"
do
setup
do
AWS
::
S3
::
Base
.
stubs
(
:establish_connection!
)
...
...
@@ -131,7 +159,7 @@ class StorageTest < Test::Unit::TestCase
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
StringIO
.
new
(
"."
)
AWS
::
S3
::
S3Object
.
expects
(
:url_for
).
with
(
"avatars/stringio.txt"
,
"prod_bucket"
,
{
:expires_in
=>
3600
})
AWS
::
S3
::
S3Object
.
expects
(
:url_for
).
with
(
"avatars/stringio.txt"
,
"prod_bucket"
,
{
:expires_in
=>
3600
,
:use_ssl
=>
false
})
@dummy
.
avatar
.
expiring_url
end
...
...
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