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
808d2950
Commit
808d2950
authored
Nov 02, 2009
by
Matt Hawkins
Committed by
Jon Yurek
Dec 01, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added method to generate an time expiring url
(cherry picked from commit 61dbcb3e36c0bc9742d045dd1e54f846043a1569)
parent
3f938287
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
lib/paperclip/storage.rb
+4
-0
test/storage_test.rb
+27
-0
No files found.
lib/paperclip/storage.rb
View file @
808d2950
...
...
@@ -160,6 +160,10 @@ module Paperclip
end
end
def
expiring_url
(
time
=
3600
)
AWS
::
S3
::
S3Object
.
url_for
(
path
,
bucket_name
,
:expires_in
=>
time
)
end
def
bucket_name
@bucket
end
...
...
test/storage_test.rb
View file @
808d2950
...
...
@@ -97,6 +97,33 @@ class StorageTest < Test::Unit::TestCase
end
end
context
"Generating a 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"
,
: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
})
@dummy
.
avatar
.
expiring_url
end
should
"should succeed"
do
assert
true
end
end
context
"Parsing S3 credentials with a bucket in them"
do
setup
do
AWS
::
S3
::
Base
.
stubs
(
:establish_connection!
)
...
...
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