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
45e4b075
Commit
45e4b075
authored
May 18, 2012
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor previous: move complexity into s3_permissions method
parent
5ce04edb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
lib/paperclip/storage/s3.rb
+8
-8
No files found.
lib/paperclip/storage/s3.rb
View file @
45e4b075
...
@@ -150,16 +150,13 @@ module Paperclip
...
@@ -150,16 +150,13 @@ module Paperclip
end
end
Paperclip
.
interpolates
(
:s3_alias_url
)
do
|
attachment
,
style
|
Paperclip
.
interpolates
(
:s3_alias_url
)
do
|
attachment
,
style
|
url_prefix
=
(
s3_protocol
=
attachment
.
s3_protocol
(
style
)).
present?
?
"
#{
s3_protocol
}
:"
:
""
"
#{
attachment
.
s3_protocol
(
style
)
}
//
#{
attachment
.
s3_host_alias
}
/
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
"
#{
url_prefix
}
//
#{
attachment
.
s3_host_alias
}
/
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
end
unless
Paperclip
::
Interpolations
.
respond_to?
:s3_alias_url
end
unless
Paperclip
::
Interpolations
.
respond_to?
:s3_alias_url
Paperclip
.
interpolates
(
:s3_path_url
)
do
|
attachment
,
style
|
Paperclip
.
interpolates
(
:s3_path_url
)
do
|
attachment
,
style
|
url_prefix
=
(
s3_protocol
=
attachment
.
s3_protocol
(
style
)).
present?
?
"
#{
s3_protocol
}
:"
:
""
"
#{
attachment
.
s3_protocol
(
style
)
}
//
#{
attachment
.
s3_host_name
}
/
#{
attachment
.
bucket_name
}
/
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
"
#{
url_prefix
}
//
#{
attachment
.
s3_host_name
}
/
#{
attachment
.
bucket_name
}
/
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
end
unless
Paperclip
::
Interpolations
.
respond_to?
:s3_path_url
end
unless
Paperclip
::
Interpolations
.
respond_to?
:s3_path_url
Paperclip
.
interpolates
(
:s3_domain_url
)
do
|
attachment
,
style
|
Paperclip
.
interpolates
(
:s3_domain_url
)
do
|
attachment
,
style
|
url_prefix
=
(
s3_protocol
=
attachment
.
s3_protocol
(
style
)).
present?
?
"
#{
s3_protocol
}
:"
:
""
"
#{
attachment
.
s3_protocol
(
style
)
}
//
#{
attachment
.
bucket_name
}
.
#{
attachment
.
s3_host_name
}
/
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
"
#{
url_prefix
}
//
#{
attachment
.
bucket_name
}
.
#{
attachment
.
s3_host_name
}
/
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
end
unless
Paperclip
::
Interpolations
.
respond_to?
:s3_domain_url
end
unless
Paperclip
::
Interpolations
.
respond_to?
:s3_domain_url
Paperclip
.
interpolates
(
:asset_host
)
do
|
attachment
,
style
|
Paperclip
.
interpolates
(
:asset_host
)
do
|
attachment
,
style
|
"
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
"
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
...
@@ -284,11 +281,14 @@ module Paperclip
...
@@ -284,11 +281,14 @@ module Paperclip
end
end
def
s3_protocol
(
style
=
default_style
)
def
s3_protocol
(
style
=
default_style
)
if
@s3_protocol
.
is_a?
(
Proc
)
protocol
=
if
@s3_protocol
.
is_a?
(
Proc
)
@s3_protocol
.
call
(
style
,
self
)
@s3_protocol
.
call
(
style
,
self
)
else
else
@s3_protocol
@s3_protocol
end
end
protocol
=
protocol
.
split
(
":"
).
first
+
":"
unless
protocol
.
empty?
protocol
end
end
def
create_bucket
def
create_bucket
...
@@ -360,7 +360,7 @@ module Paperclip
...
@@ -360,7 +360,7 @@ module Paperclip
private
:find_credentials
private
:find_credentials
def
use_secure_protocol?
(
style_name
)
def
use_secure_protocol?
(
style_name
)
s3_protocol
(
style_name
)
==
"https"
s3_protocol
(
style_name
)
==
"https
:
"
end
end
private
:use_secure_protocol?
private
:use_secure_protocol?
end
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