As a result of the current upload process some files end up corrupted in the site storage and some of those are truncated files. We can't tell if the user uploads a truncated file or if the file gets truncated during the upload.
One way of reducing the number of truncated files is to ensure that what the user selects for upload ends up whole on the server by checking the checksum of the file before upload with the checksum of the file on the server after upload.
What
[x] compute the checksum of a file selected for upload before uploading it and send it to the server along with the upload
[x] compute the checksum of a file once uploaded to the server and compare it with the checksum computed before upload
[x] do not store files where checksums differ as that points to a transfer error
[x] notify user that upload failed if checksums differ so the user retries the upload
[x] log both checksums and the compare result so that devs/admins can later troubleshoot issues
Notes
This site is a good example on how to compute a file checksum from the client side: http://onlinemd5.com/
Why
As a result of the current upload process some files end up corrupted in the site storage and some of those are truncated files. We can't tell if the user uploads a truncated file or if the file gets truncated during the upload.
One way of reducing the number of truncated files is to ensure that what the user selects for upload ends up whole on the server by checking the checksum of the file before upload with the checksum of the file on the server after upload.
What
Notes
This site is a good example on how to compute a file checksum from the client side: http://onlinemd5.com/