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
1c91f715
Commit
1c91f715
authored
Jul 14, 2011
by
takuyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
available s3 tokyo region
parent
dcad54d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
lib/paperclip/storage/s3.rb
+14
-2
No files found.
lib/paperclip/storage/s3.rb
View file @
1c91f715
...
...
@@ -66,6 +66,7 @@ module Paperclip
# to interpolate. Keys should be unique, like filenames, and despite the fact that
# S3 (strictly speaking) does not support directories, you can still use a / to
# separate parts of your file name.
# * +region+: If you are using your bucket in Tokyo region, "tokyo" write.
module
S3
def
self
.
extended
base
begin
...
...
@@ -77,6 +78,7 @@ module Paperclip
base
.
instance_eval
do
@s3_credentials
=
parse_credentials
(
@options
[
:s3_credentials
])
@region
=
@options
[
:region
]
||
@s3_credentials
[
:region
]
@bucket
=
@options
[
:bucket
]
||
@s3_credentials
[
:bucket
]
@bucket
=
@bucket
.
call
(
self
)
if
@bucket
.
is_a?
(
Proc
)
@s3_options
=
@options
[
:s3_options
]
||
{}
...
...
@@ -102,10 +104,10 @@ module Paperclip
"
#{
attachment
.
s3_protocol
(
style
)
}
://
#{
attachment
.
s3_host_alias
}
/
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
end
unless
Paperclip
::
Interpolations
.
respond_to?
:s3_alias_url
Paperclip
.
interpolates
(
:s3_path_url
)
do
|
attachment
,
style
|
"
#{
attachment
.
s3_protocol
(
style
)
}
://
s3.amazonaws.com
/
#{
attachment
.
bucket_name
}
/
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
"
#{
attachment
.
s3_protocol
(
style
)
}
://
#{
attachment
.
s3_host_name
}
/
#{
attachment
.
bucket_name
}
/
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
end
unless
Paperclip
::
Interpolations
.
respond_to?
:s3_path_url
Paperclip
.
interpolates
(
:s3_domain_url
)
do
|
attachment
,
style
|
"
#{
attachment
.
s3_protocol
(
style
)
}
://
#{
attachment
.
bucket_name
}
.
s3.amazonaws.com
/
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
"
#{
attachment
.
s3_protocol
(
style
)
}
://
#{
attachment
.
bucket_name
}
.
#{
attachment
.
s3_host_name
}
/
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
end
unless
Paperclip
::
Interpolations
.
respond_to?
:s3_domain_url
Paperclip
.
interpolates
(
:asset_host
)
do
|
attachment
,
style
|
"
#{
attachment
.
path
(
style
).
gsub
(
%r{^/}
,
""
)
}
"
...
...
@@ -120,6 +122,16 @@ module Paperclip
@bucket
end
def
s3_host_name
case
@region
when
"tokyo"
AWS
::
S3
::
DEFAULT_HOST
.
replace
"s3-ap-northeast-1.amazonaws.com"
"s3-ap-northeast-1.amazonaws.com"
else
"s3.amazonaws.com"
end
end
def
set_permissions
permissions
if
permissions
.
is_a?
(
Hash
)
permissions
[
:default
]
=
permissions
[
:default
]
||
:public_read
...
...
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