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
dcd2774e
Commit
dcd2774e
authored
Feb 05, 2013
by
Les Hill
Committed by
Jon Yurek
Feb 15, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor style specific headers code
Allow either a hash or a Style object to set the headers.
parent
74b829f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
lib/paperclip/storage/s3.rb
+4
-3
test/storage/s3_test.rb
+5
-3
No files found.
lib/paperclip/storage/s3.rb
View file @
dcd2774e
...
...
@@ -311,9 +311,10 @@ module Paperclip
end
style_specific_options
=
styles
[
style
]
if
style_specific_options
.
is_a?
(
Hash
)
merge_s3_headers
(
style_specific_options
[
:s3_headers
],
@s3_headers
,
@s3_metadata
)
if
style_specific_options
.
has_key?
(
:s3_headers
)
@s3_metadata
.
merge!
(
style_specific_options
[
:s3_metadata
])
if
style_specific_options
.
has_key?
(
:s3_metadata
)
if
style_specific_options
merge_s3_headers
(
style_specific_options
[
:s3_headers
],
@s3_headers
,
@s3_metadata
)
if
style_specific_options
[
:s3_headers
]
@s3_metadata
.
merge!
(
style_specific_options
[
:s3_metadata
])
if
style_specific_options
[
:s3_metadata
]
end
write_options
[
:metadata
]
=
@s3_metadata
unless
@s3_metadata
.
empty?
...
...
test/storage/s3_test.rb
View file @
dcd2774e
...
...
@@ -294,7 +294,7 @@ class S3Test < Test::Unit::TestCase
context
"An attachment that uses S3 for storage and has a proc for styles"
do
setup
do
rebuild_model
:styles
=>
lambda
{
|
attachment
|
attachment
.
instance
.
counter
;
{
:thumbnail
=>
'20x20#'
}
},
rebuild_model
:styles
=>
lambda
{
|
attachment
|
attachment
.
instance
.
counter
;
{
:thumbnail
=>
{
:geometry
=>
"50x50#"
,
:s3_headers
=>
{
'Cache-Control'
=>
'max-age=31557600'
}}
}
},
:storage
=>
:s3
,
:bucket
=>
"bucket"
,
:path
=>
":attachment/:style/:basename.:extension"
,
...
...
@@ -317,8 +317,10 @@ class S3Test < Test::Unit::TestCase
@dummy
.
avatar
=
@file
object
=
stub
@dummy
.
avatar
.
stubs
(
:s3_object
).
returns
(
object
)
object
.
expects
(
:write
).
with
(
anything
,
anything
).
twice
@dummy
.
avatar
.
stubs
(
:s3_object
).
with
(
:original
).
returns
(
object
)
@dummy
.
avatar
.
stubs
(
:s3_object
).
with
(
:thumbnail
).
returns
(
object
)
object
.
expects
(
:write
).
with
(
anything
,
:content_type
=>
'image/png'
,
:acl
=>
:public_read
)
object
.
expects
(
:write
).
with
(
anything
,
:content_type
=>
'image/png'
,
:acl
=>
:public_read
,
:cache_control
=>
'max-age=31557600'
)
@dummy
.
save
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