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
ccaaaad6
Commit
ccaaaad6
authored
Jun 13, 2015
by
David Chen
Committed by
Jon Yurek
Aug 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First pass at making specs run with Aws-v2
parent
9ef9b512
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
lib/paperclip/storage/s3.rb
+13
-5
spec/paperclip/storage/s3_spec.rb
+0
-0
No files found.
lib/paperclip/storage/s3.rb
View file @
ccaaaad6
...
@@ -116,7 +116,11 @@ module Paperclip
...
@@ -116,7 +116,11 @@ module Paperclip
begin
begin
require
'aws-sdk'
require
'aws-sdk'
const_set
(
'AWS_CLASS'
,
defined?
(
::
Aws
)
?
::
Aws
:
::
AWS
)
const_set
(
'AWS_CLASS'
,
defined?
(
::
Aws
)
?
::
Aws
:
::
AWS
)
const_set
(
'DEFAULT_PERMISSION'
,
defined?
(
::
AWS
)
?
:
public_read
:
:'public-read'
)
const_set
(
'AWS_BASE_ERROR'
,
defined?
(
::
Aws
)
?
Aws
::
Errors
::
ServiceError
:
AWS
::
Errors
::
Base
)
const_set
(
'DEFAULT_PERMISSION'
,
defined?
(
::
AWS
)
?
:
public_read
:
:'public-read'
)
rescue
LoadError
=>
e
rescue
LoadError
=>
e
e
.
message
<<
" (You may need to install the aws-sdk gem)"
e
.
message
<<
" (You may need to install the aws-sdk gem)"
raise
e
raise
e
...
@@ -253,7 +257,7 @@ module Paperclip
...
@@ -253,7 +257,7 @@ module Paperclip
config
[
:proxy_uri
]
=
URI
::
HTTP
.
build
(
proxy_opts
)
config
[
:proxy_uri
]
=
URI
::
HTTP
.
build
(
proxy_opts
)
end
end
[
:access_key_id
,
:secret_access_key
,
:credential_provider
].
each
do
|
opt
|
[
:access_key_id
,
:secret_access_key
,
:credential_provider
,
:credentials
].
each
do
|
opt
|
config
[
opt
]
=
s3_credentials
[
opt
]
if
s3_credentials
[
opt
]
config
[
opt
]
=
s3_credentials
[
opt
]
if
s3_credentials
[
opt
]
end
end
...
@@ -332,7 +336,7 @@ module Paperclip
...
@@ -332,7 +336,7 @@ module Paperclip
else
else
false
false
end
end
rescue
AWS_
CLASS
::
Errors
::
Base
=>
e
rescue
AWS_
BASE_ERROR
=>
e
false
false
end
end
...
@@ -358,7 +362,11 @@ module Paperclip
...
@@ -358,7 +362,11 @@ module Paperclip
end
end
def
create_bucket
def
create_bucket
if
aws_v1?
s3_interface
.
buckets
.
create
(
bucket_name
)
s3_interface
.
buckets
.
create
(
bucket_name
)
else
s3_interface
.
bucket
(
bucket_name
).
create
end
end
end
def
flush_writes
#:nodoc:
def
flush_writes
#:nodoc:
...
@@ -426,7 +434,7 @@ module Paperclip
...
@@ -426,7 +434,7 @@ module Paperclip
else
else
s3_bucket
.
object
(
path
.
sub
(
%r{
\A
/}
,
''
))
s3_bucket
.
object
(
path
.
sub
(
%r{
\A
/}
,
''
))
end
.
delete
end
.
delete
rescue
AWS_
CLASS
::
Errors
::
Base
=>
e
rescue
AWS_
BASE_ERROR
=>
e
# Ignore this.
# Ignore this.
end
end
end
end
...
@@ -440,7 +448,7 @@ module Paperclip
...
@@ -440,7 +448,7 @@ module Paperclip
local_file
.
write
(
chunk
)
local_file
.
write
(
chunk
)
end
end
end
end
rescue
AWS_
CLASS
::
Errors
::
Base
=>
e
rescue
AWS_
BASE_ERROR
=>
e
warn
(
"
#{
e
}
- cannot copy
#{
path
(
style
)
}
to local file
#{
local_dest_path
}
"
)
warn
(
"
#{
e
}
- cannot copy
#{
path
(
style
)
}
to local file
#{
local_dest_path
}
"
)
false
false
end
end
...
...
spec/paperclip/storage/s3_spec.rb
View file @
ccaaaad6
This diff is collapsed.
Click to expand it.
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