问题
I am really confused about this:
from the officially paperclip wiki page:
A MD5 checksum of the original file assigned will be placed in the model if it has an attribute named fingerprint.
I have a attachment_fingerprint
in my table and paperclip will insert the md5 value into that field automatically.
The question is, how is the checksum generated? is it generated before the upload or after the upload?
For example, the original file has a checksum 1 and the file get corrupted during the uploading process and its checksum now become 2, which value will paperclip insert into the field?
回答1:
The fingerprint checksum is computed and saved to the fingerprint column after the file has been successfully uploaded to server. It's very unlikely that the file would get corrupted during the upload process, though. If you're really concerned about this, you'd have to precompute the same MD5 on the client, send it along with the uploaded file and on the server check the original MD5 hash against the one Paperclip computes.
来源:https://stackoverflow.com/questions/15282130/rails-how-does-md5-checksum-work-in-paperclip