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
76f825a8
Commit
76f825a8
authored
Dec 23, 2015
by
Tute Costa
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2075 from thoughtbot/tc-remove-aws-v1
Remove AWS v1 support
parents
2fe81fb9
d55b4456
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
79 deletions
+13
-79
.travis.yml
+0
-1
Appraisals
+0
-5
README.md
+1
-5
UPGRADING
+0
-5
gemfiles/4.2.awsv1.gemfile
+0
-17
lib/paperclip/storage/s3.rb
+12
-46
No files found.
.travis.yml
View file @
76f825a8
...
@@ -8,7 +8,6 @@ script: "bundle exec rake clean spec cucumber"
...
@@ -8,7 +8,6 @@ script: "bundle exec rake clean spec cucumber"
gemfile
:
gemfile
:
-
gemfiles/4.2.awsv2.1.gemfile
-
gemfiles/4.2.awsv2.1.gemfile
-
gemfiles/4.2.awsv2.0.gemfile
-
gemfiles/4.2.awsv2.0.gemfile
-
gemfiles/4.2.awsv1.gemfile
sudo
:
false
sudo
:
false
cache
:
bundler
cache
:
bundler
Appraisals
View file @
76f825a8
...
@@ -7,8 +7,3 @@ appraise "4.2.awsv2.0" do
...
@@ -7,8 +7,3 @@ appraise "4.2.awsv2.0" do
gem "rails", "~> 4.2.0"
gem "rails", "~> 4.2.0"
gem "aws-sdk", "~> 2.0.0"
gem "aws-sdk", "~> 2.0.0"
end
end
appraise "4.2.awsv1" do
gem "rails", "~> 4.2.0"
gem "aws-sdk", "~> 1.5"
end
README.md
View file @
76f825a8
...
@@ -561,7 +561,7 @@ Storage
...
@@ -561,7 +561,7 @@ Storage
Paperclip ships with 3 storage adapters:
Paperclip ships with 3 storage adapters:
*
File Storage
*
File Storage
*
S3 Storage (via
`aws-sdk`
or
`aws-sdk-v1`
)
*
S3 Storage (via
`aws-sdk`
)
*
Fog Storage
*
Fog Storage
If you would like to use Paperclip with another storage, you can install these
If you would like to use Paperclip with another storage, you can install these
...
@@ -591,10 +591,6 @@ the `aws-sdk` gem in your Gemfile:
...
@@ -591,10 +591,6 @@ the `aws-sdk` gem in your Gemfile:
```
ruby
```
ruby
gem
'aws-sdk'
,
'>= 2.0.0'
# If using paperclip `master` (upcoming v5.0)
gem
'aws-sdk'
,
'>= 2.0.0'
# If using paperclip `master` (upcoming v5.0)
```
```
or
```
ruby
gem
'aws-sdk-v1'
# If using paperclip <= v4.3.1
```
And then you can specify using S3 from
`has_attached_file`
.
And then you can specify using S3 from
`has_attached_file`
.
You can find more information about configuring and using S3 storage in
You can find more information about configuring and using S3 storage in
...
...
UPGRADING
View file @
76f825a8
...
@@ -12,8 +12,3 @@ changes:
...
@@ -12,8 +12,3 @@ changes:
note that the format of the permissions changed from using an underscore to
note that the format of the permissions changed from using an underscore to
using a hyphen. For example, `:public_read` needs to be changed to
using a hyphen. For example, `:public_read` needs to be changed to
`public-read`.
`public-read`.
If you want to continue using an earlier version of aws-sdk, replace
aws-sdk with aws-sdk-v1 in your Gemfile.
If both are in your Gemfile, paperclip will use aws-sdk v2.
gemfiles/4.2.awsv1.gemfile
deleted
100644 → 0
View file @
2fe81fb9
# This file was generated by Appraisal
source "https://rubygems.org"
gem "sqlite3", "~> 1.3.8", platforms: :ruby
gem "pry"
gem "rails", "~> 4.2.0"
gem "aws-sdk", "~> 1.5"
group :development, :test do
gem "activerecord-import"
gem "mime-types", "~> 1.16"
gem "builder"
gem "rubocop", :require => false
end
gemspec path: "../"
lib/paperclip/storage/s3.rb
View file @
76f825a8
...
@@ -41,7 +41,7 @@ module Paperclip
...
@@ -41,7 +41,7 @@ module Paperclip
# * +s3_permissions+: This is a String that should be one of the "canned" access
# * +s3_permissions+: This is a String that should be one of the "canned" access
# policies that S3 provides (more information can be found here:
# policies that S3 provides (more information can be found here:
# http://docs.aws.amazon.com/AmazonS3/latest/dev/ACLOverview.html)
# http://docs.aws.amazon.com/AmazonS3/latest/dev/ACLOverview.html)
# The default for Paperclip is
:public_read (aws-sdk v1) / public-read (aws-sdk v2)
.
# The default for Paperclip is
public-read
.
#
#
# You can set permission on a per style bases by doing the following:
# You can set permission on a per style bases by doing the following:
# :s3_permissions => {
# :s3_permissions => {
...
@@ -194,13 +194,11 @@ module Paperclip
...
@@ -194,13 +194,11 @@ module Paperclip
def
expiring_url
(
time
=
3600
,
style_name
=
default_style
)
def
expiring_url
(
time
=
3600
,
style_name
=
default_style
)
if
path
(
style_name
)
if
path
(
style_name
)
if
aws_v1?
base_options
=
{
expires_in:
time
}
base_options
=
{
:expires
=>
time
,
:secure
=>
use_secure_protocol?
(
style_name
)
}
s3_object
(
style_name
).
presigned_url
(
s3_object
(
style_name
).
url_for
(
:read
,
base_options
.
merge
(
s3_url_options
)).
to_s
:get
,
else
base_options
.
merge
(
s3_url_options
),
base_options
=
{
:expires_in
=>
time
}
).
to_s
s3_object
(
style_name
).
presigned_url
(
:get
,
base_options
.
merge
(
s3_url_options
)).
to_s
end
else
else
url
(
style_name
)
url
(
style_name
)
end
end
...
@@ -244,11 +242,7 @@ module Paperclip
...
@@ -244,11 +242,7 @@ module Paperclip
def
s3_interface
def
s3_interface
@s3_interface
||=
begin
@s3_interface
||=
begin
config
=
if
aws_v1?
config
=
{
region:
s3_region
}
{
:s3_endpoint
=>
s3_host_name
}
else
{
:region
=>
s3_region
}
end
if
using_http_proxy?
if
using_http_proxy?
...
@@ -272,19 +266,11 @@ module Paperclip
...
@@ -272,19 +266,11 @@ module Paperclip
def
obtain_s3_instance_for
(
options
)
def
obtain_s3_instance_for
(
options
)
instances
=
(
Thread
.
current
[
:paperclip_s3_instances
]
||=
{})
instances
=
(
Thread
.
current
[
:paperclip_s3_instances
]
||=
{})
instances
[
options
]
||=
if
aws_v1?
instances
[
options
]
||=
AWS_CLASS
::
S3
::
Resource
.
new
(
options
)
AWS_CLASS
::
S3
.
new
(
options
)
else
AWS_CLASS
::
S3
::
Resource
.
new
(
options
)
end
end
end
def
s3_bucket
def
s3_bucket
@s3_bucket
||=
if
aws_v1?
@s3_bucket
||=
s3_interface
.
bucket
(
bucket_name
)
s3_interface
.
buckets
[
bucket_name
]
else
s3_interface
.
bucket
(
bucket_name
)
end
end
end
def
style_name_as_path
(
style_name
)
def
style_name_as_path
(
style_name
)
...
@@ -292,11 +278,7 @@ module Paperclip
...
@@ -292,11 +278,7 @@ module Paperclip
end
end
def
s3_object
style_name
=
default_style
def
s3_object
style_name
=
default_style
if
aws_v1?
s3_bucket
.
object
style_name_as_path
(
style_name
)
s3_bucket
.
objects
[
style_name_as_path
(
style_name
)]
else
s3_bucket
.
object
(
style_name_as_path
(
style_name
))
end
end
end
def
using_http_proxy?
def
using_http_proxy?
...
@@ -367,12 +349,8 @@ module Paperclip
...
@@ -367,12 +349,8 @@ module Paperclip
end
end
def
create_bucket
def
create_bucket
if
aws_v1?
s3_interface
.
buckets
.
create
(
bucket_name
)
else
s3_interface
.
bucket
(
bucket_name
).
create
s3_interface
.
bucket
(
bucket_name
).
create
end
end
end
def
flush_writes
#:nodoc:
def
flush_writes
#:nodoc:
@queued_for_write
.
each
do
|
style
,
file
|
@queued_for_write
.
each
do
|
style
,
file
|
...
@@ -402,11 +380,7 @@ module Paperclip
...
@@ -402,11 +380,7 @@ module Paperclip
write_options
[
:metadata
]
=
@s3_metadata
unless
@s3_metadata
.
empty?
write_options
[
:metadata
]
=
@s3_metadata
unless
@s3_metadata
.
empty?
write_options
.
merge!
(
@s3_headers
)
write_options
.
merge!
(
@s3_headers
)
if
aws_v1?
s3_object
(
style
).
write
(
file
,
write_options
)
else
s3_object
(
style
).
upload_file
(
file
.
path
,
write_options
)
s3_object
(
style
).
upload_file
(
file
.
path
,
write_options
)
end
rescue
AWS_CLASS
::
S3
::
Errors
::
NoSuchBucket
rescue
AWS_CLASS
::
S3
::
Errors
::
NoSuchBucket
create_bucket
create_bucket
retry
retry
...
@@ -432,11 +406,7 @@ module Paperclip
...
@@ -432,11 +406,7 @@ module Paperclip
@queued_for_delete
.
each
do
|
path
|
@queued_for_delete
.
each
do
|
path
|
begin
begin
log
(
"deleting
#{
path
}
"
)
log
(
"deleting
#{
path
}
"
)
if
aws_v1?
s3_bucket
.
object
(
path
.
sub
(
%r{
\A
/}
,
""
)).
delete
s3_bucket
.
objects
[
path
.
sub
(
%r{
\A
/}
,
''
)]
else
s3_bucket
.
object
(
path
.
sub
(
%r{
\A
/}
,
''
))
end
.
delete
rescue
AWS_BASE_ERROR
=>
e
rescue
AWS_BASE_ERROR
=>
e
# Ignore this.
# Ignore this.
end
end
...
@@ -447,7 +417,7 @@ module Paperclip
...
@@ -447,7 +417,7 @@ module Paperclip
def
copy_to_local_file
(
style
,
local_dest_path
)
def
copy_to_local_file
(
style
,
local_dest_path
)
log
(
"copying
#{
path
(
style
)
}
to local file
#{
local_dest_path
}
"
)
log
(
"copying
#{
path
(
style
)
}
to local file
#{
local_dest_path
}
"
)
::
File
.
open
(
local_dest_path
,
'wb'
)
do
|
local_file
|
::
File
.
open
(
local_dest_path
,
'wb'
)
do
|
local_file
|
s3_object
(
style
).
send
(
aws_v1?
?
:
read
:
:get
)
do
|
chunk
|
s3_object
(
style
).
get
do
|
chunk
|
local_file
.
write
(
chunk
)
local_file
.
write
(
chunk
)
end
end
end
end
...
@@ -458,10 +428,6 @@ module Paperclip
...
@@ -458,10 +428,6 @@ module Paperclip
private
private
def
aws_v1?
Gem
::
Version
.
new
(
AWS_CLASS
::
VERSION
)
<
Gem
::
Version
.
new
(
2
)
end
def
find_credentials
creds
def
find_credentials
creds
case
creds
case
creds
when
File
when
File
...
...
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