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
48293005
Commit
48293005
authored
May 03, 2011
by
Lance Ivy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add :fog_file hash to support cache-control and expires headers
parent
93753d5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
20 deletions
+10
-20
lib/paperclip/storage/fog.rb
+3
-2
test/fog_test.rb
+7
-18
No files found.
lib/paperclip/storage/fog.rb
View file @
48293005
...
...
@@ -15,6 +15,7 @@ module Paperclip
@fog_credentials
=
@options
[
:fog_credentials
]
@fog_host
=
@options
[
:fog_host
]
@fog_public
=
@options
[
:fog_public
]
@fog_file
=
@options
[
:fog_file
]
||
{}
@url
=
':fog_public_url'
Paperclip
.
interpolates
(
:fog_public_url
)
do
|
attachment
,
style
|
...
...
@@ -34,11 +35,11 @@ module Paperclip
def
flush_writes
for
style
,
file
in
@queued_for_write
do
log
(
"saving
#{
path
(
style
)
}
"
)
directory
.
files
.
create
(
directory
.
files
.
create
(
@fog_file
.
merge
(
:body
=>
file
,
:key
=>
path
(
style
),
:public
=>
@fog_public
)
)
)
end
@queued_for_write
=
{}
end
...
...
test/fog_test.rb
View file @
48293005
...
...
@@ -17,14 +17,17 @@ class FogTest < Test::Unit::TestCase
@connection
=
Fog
::
Storage
.
new
(
@credentials
)
rebuild_model
(
@options
=
{
:fog_directory
=>
@fog_directory
,
:fog_credentials
=>
@credentials
,
:fog_host
=>
nil
,
:fog_public
=>
true
,
:fog_file
=>
{
:cache_control
=>
1234
},
:path
=>
":attachment/:basename.:extension"
,
:storage
=>
:fog
)
}
rebuild_model
(
@options
)
end
should
"be extended by the Fog module"
do
...
...
@@ -63,14 +66,7 @@ class FogTest < Test::Unit::TestCase
context
"without a fog_host"
do
setup
do
rebuild_model
(
:fog_directory
=>
@fog_directory
,
:fog_credentials
=>
@credentials
,
:fog_host
=>
nil
,
:fog_public
=>
true
,
:path
=>
":attachment/:basename.:extension"
,
:storage
=>
:fog
)
rebuild_model
(
@options
.
merge
(
:fog_host
=>
nil
))
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
StringIO
.
new
(
'.'
)
@dummy
.
save
...
...
@@ -83,14 +79,7 @@ class FogTest < Test::Unit::TestCase
context
"with a fog_host"
do
setup
do
rebuild_model
(
:fog_directory
=>
@fog_directory
,
:fog_credentials
=>
@credentials
,
:fog_host
=>
'http://example.com'
,
:fog_public
=>
true
,
:path
=>
":attachment/:basename.:extension"
,
:storage
=>
:fog
)
rebuild_model
(
@options
.
merge
(
:fog_host
=>
'http://example.com'
))
@dummy
=
Dummy
.
new
@dummy
.
avatar
=
StringIO
.
new
(
'.'
)
@dummy
.
save
...
...
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