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
9d1355b5
Commit
9d1355b5
authored
Apr 14, 2012
by
Sebastien Guignot
Committed by
Prem Sichanugrist
Apr 17, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix attachment.reprocess! when using storage providers fog and s3.
parent
02d99ec3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
3 deletions
+37
-3
lib/paperclip/io_adapters/attachment_adapter.rb
+10
-1
lib/paperclip/storage/fog.rb
+11
-0
lib/paperclip/storage/s3.rb
+11
-0
test/storage/s3_live_test.rb
+5
-2
No files found.
lib/paperclip/io_adapters/attachment_adapter.rb
View file @
9d1355b5
...
...
@@ -30,6 +30,11 @@ module Paperclip
@tempfile
.
read
(
length
,
buffer
)
end
# We don't use this directly, but aws/sdk does.
def
rewind
@tempfile
.
rewind
end
def
eof?
@tempfile
.
eof?
end
...
...
@@ -50,7 +55,11 @@ module Paperclip
def
copy_to_tempfile
(
src
)
dest
=
Tempfile
.
new
(
src
.
original_filename
)
dest
.
binmode
FileUtils
.
cp
(
src
.
path
(
:original
),
dest
.
path
)
if
src
.
respond_to?
:copy_to_local_file
src
.
copy_to_local_file
(
:original
,
dest
.
path
)
else
FileUtils
.
cp
(
src
.
path
(
:original
),
dest
.
path
)
end
dest
end
...
...
lib/paperclip/storage/fog.rb
View file @
9d1355b5
...
...
@@ -135,6 +135,17 @@ module Paperclip
(
creds
[
env
]
||
creds
).
symbolize_keys
end
def
copy_to_local_file
(
style
,
local_dest_path
)
log
(
"copying
#{
path
(
style
)
}
to local file
#{
local_dest_path
}
"
)
local_file
=
::
File
.
open
(
local_dest_path
,
'wb'
)
file
=
directory
.
files
.
get
(
path
(
style
))
local_file
.
write
(
file
.
body
)
local_file
.
close
rescue
Fog
::
Errors
::
Error
=>
e
warn
(
"
#{
e
}
- cannot copy
#{
path
(
style
)
}
to local file
#{
local_dest_path
}
"
)
false
end
private
def
find_credentials
(
creds
)
...
...
lib/paperclip/storage/s3.rb
View file @
9d1355b5
...
...
@@ -307,6 +307,17 @@ module Paperclip
@queued_for_delete
=
[]
end
def
copy_to_local_file
(
style
,
local_dest_path
)
log
(
"copying
#{
path
(
style
)
}
to local file
#{
local_dest_path
}
"
)
local_file
=
::
File
.
open
(
local_dest_path
,
'wb'
)
file
=
s3_object
(
style
)
local_file
.
write
(
file
.
read
)
local_file
.
close
rescue
AWS
::
Errors
::
Base
=>
e
warn
(
"
#{
e
}
- cannot copy
#{
path
(
style
)
}
to local file
#{
local_dest_path
}
"
)
false
end
def
find_credentials
creds
case
creds
when
File
...
...
test/storage/s3_live_test.rb
View file @
9d1355b5
require
'./test/helper'
require
'aws'
unless
ENV
[
"S3_BUCKET"
].
blank?
class
S3LiveTest
<
Test
::
Unit
::
TestCase
...
...
@@ -105,7 +104,11 @@ unless ENV["S3_BUCKET"].blank?
assert_success_response
@dummy
.
avatar
.
url
end
should
"be destoryable"
do
should
"be reprocessable"
do
assert
@dummy
.
avatar
.
reprocess!
end
should
"be destroyable"
do
url
=
@dummy
.
avatar
.
url
@dummy
.
destroy
assert_not_found_response
url
...
...
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