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
ad176ba6
Commit
ad176ba6
authored
Jan 03, 2014
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass an Integer or a Time to #expiring_url
parent
0f4029c1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
lib/paperclip/storage/fog.rb
+8
-0
test/storage/fog_test.rb
+10
-0
test/storage/s3_test.rb
+4
-0
No files found.
lib/paperclip/storage/fog.rb
View file @
ad176ba6
...
@@ -139,6 +139,7 @@ module Paperclip
...
@@ -139,6 +139,7 @@ module Paperclip
end
end
def
expiring_url
(
time
=
(
Time
.
now
+
3600
),
style
=
default_style
)
def
expiring_url
(
time
=
(
Time
.
now
+
3600
),
style
=
default_style
)
time
=
convert_time
(
time
)
if
directory
.
files
.
respond_to?
(
:get_http_url
)
if
directory
.
files
.
respond_to?
(
:get_http_url
)
expiring_url
=
directory
.
files
.
get_http_url
(
path
(
style
),
time
)
expiring_url
=
directory
.
files
.
get_http_url
(
path
(
style
),
time
)
...
@@ -171,6 +172,13 @@ module Paperclip
...
@@ -171,6 +172,13 @@ module Paperclip
private
private
def
convert_time
(
time
)
if
time
.
is_a?
(
Fixnum
)
time
=
Time
.
now
+
time
end
time
end
def
dynamic_fog_host_for_style
(
style
)
def
dynamic_fog_host_for_style
(
style
)
if
@options
[
:fog_host
].
respond_to?
(
:call
)
if
@options
[
:fog_host
].
respond_to?
(
:call
)
@options
[
:fog_host
].
call
(
self
)
@options
[
:fog_host
].
call
(
self
)
...
...
test/storage/fog_test.rb
View file @
ad176ba6
...
@@ -317,6 +317,16 @@ class FogTest < Test::Unit::TestCase
...
@@ -317,6 +317,16 @@ class FogTest < Test::Unit::TestCase
end
end
end
end
context
"generating an expiring url"
do
should
"generate the same url when using Times and Integer offsets"
do
rebuild_model
(
@options
)
dummy
=
Dummy
.
new
dummy
.
avatar
=
StringIO
.
new
(
'.'
)
assert_equal
dummy
.
avatar
.
expiring_url
(
1234
),
dummy
.
avatar
.
expiring_url
(
Time
.
now
+
1234
)
end
end
context
"with an invalid bucket name for a subdomain"
do
context
"with an invalid bucket name for a subdomain"
do
setup
do
setup
do
rebuild_model
(
@options
.
merge
(
:fog_directory
=>
"this_is_invalid"
))
rebuild_model
(
@options
.
merge
(
:fog_directory
=>
"this_is_invalid"
))
...
...
test/storage/s3_test.rb
View file @
ad176ba6
...
@@ -549,6 +549,10 @@ class S3Test < Test::Unit::TestCase
...
@@ -549,6 +549,10 @@ class S3Test < Test::Unit::TestCase
assert_equal
(
@dummy
.
avatar
.
url
,
@dummy
.
avatar
.
expiring_url
)
assert_equal
(
@dummy
.
avatar
.
url
,
@dummy
.
avatar
.
expiring_url
)
end
end
end
end
should
"generate the same url when using Times and Integer offsets"
do
assert_equal
@dummy
.
avatar
.
expiring_url
(
1234
),
@dummy
.
avatar
.
expiring_url
(
Time
.
now
+
1234
)
end
end
end
context
"Generating a url with an expiration for each style"
do
context
"Generating a url with an expiration for each style"
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