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
e90de5da
Commit
e90de5da
authored
Jun 15, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove whitespaces
parent
d46a1afe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
lib/paperclip/storage/fog.rb
+6
-6
test/storage/fog_test.rb
+9
-9
No files found.
lib/paperclip/storage/fog.rb
View file @
e90de5da
...
@@ -119,14 +119,14 @@ module Paperclip
...
@@ -119,14 +119,14 @@ module Paperclip
end
end
end
end
end
end
def
expiring_url
(
time
=
3600
,
style
=
default_style
)
def
expiring_url
(
time
=
3600
,
style
=
default_style
)
expiring_url
=
directory
.
files
.
get_http_url
(
path
(
style
),
time
)
expiring_url
=
directory
.
files
.
get_http_url
(
path
(
style
),
time
)
if
@options
[
:fog_host
]
if
@options
[
:fog_host
]
expiring_url
.
gsub!
(
/
#{
host_name_for_directory
}
/
,
dynamic_fog_host_for_style
(
style
))
expiring_url
.
gsub!
(
/
#{
host_name_for_directory
}
/
,
dynamic_fog_host_for_style
(
style
))
end
end
return
expiring_url
return
expiring_url
end
end
...
@@ -148,7 +148,7 @@ module Paperclip
...
@@ -148,7 +148,7 @@ module Paperclip
end
end
private
private
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
)
...
@@ -156,12 +156,12 @@ module Paperclip
...
@@ -156,12 +156,12 @@ module Paperclip
(
@options
[
:fog_host
]
=~
/%d/
)
?
@options
[:
fog_host
]
%
(
path
(
style
).
hash
%
4
)
:
@options
[
:fog_host
]
(
@options
[
:fog_host
]
=~
/%d/
)
?
@options
[:
fog_host
]
%
(
path
(
style
).
hash
%
4
)
:
@options
[
:fog_host
]
end
end
end
end
def
host_name_for_directory
def
host_name_for_directory
if
@options
[
:fog_directory
].
to_s
=~
Fog
::
AWS_BUCKET_SUBDOMAIN_RESTRICTON_REGEX
if
@options
[
:fog_directory
].
to_s
=~
Fog
::
AWS_BUCKET_SUBDOMAIN_RESTRICTON_REGEX
# This:
# This:
"
#{
@options
[
:fog_directory
]
}
."
"
#{
@options
[
:fog_directory
]
}
."
# Should be modified to this:
# Should be modified to this:
# "#{@options[:fog_directory]}.s3.amazonaws.com"
# "#{@options[:fog_directory]}.s3.amazonaws.com"
# When fog with https://github.com/fog/fog/pull/857 gets released
# When fog with https://github.com/fog/fog/pull/857 gets released
...
...
test/storage/fog_test.rb
View file @
e90de5da
...
@@ -208,7 +208,7 @@ class FogTest < Test::Unit::TestCase
...
@@ -208,7 +208,7 @@ class FogTest < Test::Unit::TestCase
# For now, use this passing one:
# For now, use this passing one:
assert_match
/^https:\/\/papercliptests.\/avatars\/5k.png\?\d*$/
,
@dummy
.
avatar
.
url
assert_match
/^https:\/\/papercliptests.\/avatars\/5k.png\?\d*$/
,
@dummy
.
avatar
.
url
end
end
should
"provide an url that expires in subdomain style"
do
should
"provide an url that expires in subdomain style"
do
# The following line is the correct one when this pull request in Fog is released:
# The following line is the correct one when this pull request in Fog is released:
# https://github.com/fog/fog/pull/857
# https://github.com/fog/fog/pull/857
...
@@ -236,7 +236,7 @@ class FogTest < Test::Unit::TestCase
...
@@ -236,7 +236,7 @@ class FogTest < Test::Unit::TestCase
should
"provide an url in folder style"
do
should
"provide an url in folder style"
do
assert_match
/^https:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png\?\d*$/
,
@dummy
.
avatar
.
url
assert_match
/^https:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png\?\d*$/
,
@dummy
.
avatar
.
url
end
end
should
"provide a url that expires in folder style"
do
should
"provide a url that expires in folder style"
do
assert_match
/^http:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png\?AWSAccessKeyId=.+$/
,
@dummy
.
avatar
.
expiring_url
assert_match
/^http:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png\?AWSAccessKeyId=.+$/
,
@dummy
.
avatar
.
expiring_url
end
end
...
@@ -271,9 +271,9 @@ class FogTest < Test::Unit::TestCase
...
@@ -271,9 +271,9 @@ class FogTest < Test::Unit::TestCase
should
"provide a public url"
do
should
"provide a public url"
do
assert_match
/http:\/\/dynamicfoghost\.com/
,
@dummy
.
avatar
.
url
assert_match
/http:\/\/dynamicfoghost\.com/
,
@dummy
.
avatar
.
url
end
end
end
end
context
"with a custom fog_host"
do
context
"with a custom fog_host"
do
setup
do
setup
do
rebuild_model
(
@options
.
merge
(
:fog_host
=>
"http://dynamicfoghost.com"
))
rebuild_model
(
@options
.
merge
(
:fog_host
=>
"http://dynamicfoghost.com"
))
...
@@ -281,15 +281,15 @@ class FogTest < Test::Unit::TestCase
...
@@ -281,15 +281,15 @@ class FogTest < Test::Unit::TestCase
@dummy
.
avatar
=
@file
@dummy
.
avatar
=
@file
@dummy
.
save
@dummy
.
save
end
end
should
"provide a public url"
do
should
"provide a public url"
do
assert_match
/http:\/\/dynamicfoghost\.com/
,
@dummy
.
avatar
.
url
assert_match
/http:\/\/dynamicfoghost\.com/
,
@dummy
.
avatar
.
url
end
end
should
"provide an expiring url"
do
should
"provide an expiring url"
do
assert_match
/http:\/\/dynamicfoghost\.com/
,
@dummy
.
avatar
.
expiring_url
assert_match
/http:\/\/dynamicfoghost\.com/
,
@dummy
.
avatar
.
expiring_url
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"
,
:fog_host
=>
"http://dynamicfoghost.com"
}))
rebuild_model
(
@options
.
merge
({
:fog_directory
=>
"this_is_invalid"
,
:fog_host
=>
"http://dynamicfoghost.com"
}))
...
@@ -297,12 +297,12 @@ class FogTest < Test::Unit::TestCase
...
@@ -297,12 +297,12 @@ class FogTest < Test::Unit::TestCase
@dummy
.
avatar
=
@file
@dummy
.
avatar
=
@file
@dummy
.
save
@dummy
.
save
end
end
should
"provide an expiring url"
do
should
"provide an expiring url"
do
assert_match
/http:\/\/dynamicfoghost\.com/
,
@dummy
.
avatar
.
expiring_url
assert_match
/http:\/\/dynamicfoghost\.com/
,
@dummy
.
avatar
.
expiring_url
end
end
end
end
end
end
context
"with a proc for the fog_credentials evaluating a model method"
do
context
"with a proc for the fog_credentials evaluating a model method"
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