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
41da3a3c
Commit
41da3a3c
authored
Apr 04, 2014
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure FileAdapter files have the right extension
parent
4b318160
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
8 deletions
+9
-8
lib/paperclip/io_adapters/stringio_adapter.rb
+5
-6
spec/paperclip/io_adapters/abstract_adapter_spec.rb
+0
-1
spec/paperclip/io_adapters/file_adapter_spec.rb
+4
-0
spec/paperclip/io_adapters/stringio_adapter_spec.rb
+0
-1
No files found.
lib/paperclip/io_adapters/stringio_adapter.rb
View file @
41da3a3c
...
...
@@ -2,7 +2,6 @@ module Paperclip
class
StringioAdapter
<
AbstractAdapter
def
initialize
(
target
)
@target
=
target
@tempfile
=
copy_to_tempfile
cache_current_values
end
...
...
@@ -11,15 +10,15 @@ module Paperclip
private
def
cache_current_values
self
.
original_filename
=
@target
.
original_filename
if
@target
.
respond_to?
(
:original_filename
)
self
.
original_filename
||=
"data"
@tempfile
=
copy_to_tempfile
(
@target
)
@content_type
=
ContentTypeDetector
.
new
(
@tempfile
.
path
).
detect
original_filename
=
@target
.
original_filename
if
@target
.
respond_to?
(
:original_filename
)
original_filename
||=
"data"
self
.
original_filename
=
original_filename
.
strip
@size
=
@target
.
size
end
def
copy_to_tempfile
while
data
=
@target
.
read
(
16
*
1024
)
def
copy_to_tempfile
(
source
)
while
data
=
source
.
read
(
16
*
1024
)
destination
.
write
(
data
)
end
destination
.
rewind
...
...
spec/paperclip/io_adapters/abstract_adapter_spec.rb
View file @
41da3a3c
...
...
@@ -65,7 +65,6 @@ describe Paperclip::AbstractAdapter do
it
'uses the original filename to generate the tempfile'
do
@adapter
=
TestAdapter
.
new
@adapter
.
original_filename
=
"file.png"
require
'pry'
;
binding
.
pry
expect
(
@adapter
.
send
(
:destination
).
path
).
to
end_with
(
".png"
)
end
end
spec/paperclip/io_adapters/file_adapter_spec.rb
View file @
41da3a3c
...
...
@@ -18,6 +18,10 @@ describe Paperclip::FileAdapter do
@subject
=
Paperclip
.
io_adapters
.
for
(
@file
)
end
it
'uses the original filename to generate the tempfile'
do
assert
@subject
.
path
.
ends_with?
(
".png"
)
end
it
"gets the right filename"
do
assert_equal
"5k.png"
,
@subject
.
original_filename
end
...
...
spec/paperclip/io_adapters/stringio_adapter_spec.rb
View file @
41da3a3c
...
...
@@ -56,6 +56,5 @@ describe Paperclip::StringioAdapter do
@subject
.
original_filename
=
'image:restricted.png'
expect
(
@subject
.
path
).
to_not
match
(
/:/
)
end
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