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
90cd609e
Commit
90cd609e
authored
Oct 08, 2010
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewind the file after reading it for fingerprinting
parent
f9e592ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletions
+20
-1
lib/paperclip/upfile.rb
+3
-1
test/upfile_test.rb
+17
-0
No files found.
lib/paperclip/upfile.rb
View file @
90cd609e
...
...
@@ -35,7 +35,9 @@ module Paperclip
# Returns the hash of the file.
def
fingerprint
Digest
::
MD5
.
hexdigest
(
self
.
read
)
data
=
self
.
read
self
.
rewind
Digest
::
MD5
.
hexdigest
(
data
)
end
end
end
...
...
test/upfile_test.rb
View file @
90cd609e
...
...
@@ -33,4 +33,21 @@ class UpfileTest < Test::Unit::TestCase
end
assert_equal
'text/plain'
,
file
.
content_type
end
should
"return a MD5 fingerprint of the file"
do
file
=
StringIO
.
new
(
"1234567890"
)
class
<<
file
include
Paperclip
::
Upfile
end
assert_equal
"e807f1fcf82d132f9bb018ca6738a19f"
,
file
.
fingerprint
end
should
"still be readable after the file fingerprints itself"
do
file
=
StringIO
.
new
(
"1234567890"
)
class
<<
file
include
Paperclip
::
Upfile
end
file
.
fingerprint
assert_equal
"1234567890"
,
file
.
read
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