Topic: Validating an upload - ensure no corruption in transit

Hi,

Does plupload do any hash / crc validation on uploads to mitigate against corruption in transit during the upload process?

If not, is there a suggested way to do this as part of the upload so that we can check that the file uploaded on the server is identical to the original file on the client PC?

At the moment we just trust plupload and also do a quick filesize check, but I think we need to do more.

Thanks,
Gary.

Re: Validating an upload - ensure no corruption in transit

Checksum calculation, especially on client-side is quite a performance consuming operation. While it is possible in general, might be an overkill in most of the cases.

Can you describe your usage case?

If you want to see your issue fixed, do not report it here, do it on - GitHub.

Re: Validating an upload - ensure no corruption in transit

Usage case: A user uploads a document (eg. a Word docx) onto our hosted service, using plupload in the UI, and wants to be confident that the uploaded file on our server is identical to the one he's got on his PC, especially if he's using our service as some sort of archive.  At the moment the only way they can do that is to download the document straightaway and check it.

We can mitigate against potential bit-rot once the document has been uploaded by running a regular checksum and comparing against previous one we store, but I'm looking for a way that we can confirm there's been no corruption in transit.

I understand about the performance trade-off and I'm happy with that in the cases where users have documents that are being archived.

Thanks,
Gary

Re: Validating an upload - ensure no corruption in transit

I'm happy to implement a checksum on the server side (eg. once all the chunks have been uploaded and reassembled) and pass this back to the client, but is there a recommended / suggested way to do a checksum on the client side for comparison? 

Or, is it better to checksum the chunks as they go?

Thanks,
Gary.

Re: Validating an upload - ensure no corruption in transit

Calculating a checksum on client-side is quite straightforward - you simply need to preload the whole file with FileReader and then do a checksum on the binary array or string (depends on how you preload the file) using the checksum algorithm of your choice (MD5 being the simplest). Now, you can probably write your own implementation of the MD5, but it's probably better to use some existing solution, like the port of PHPs md5 function for example, or  the Spark MD5 which is usually a recommended way to go. We do not ship any checksum calculating facilities with the Plupload, but you can easily precalculate the checksum using above mentioned libraries and then in FileUploaded handler compare it with the one created and sent with the response from your server.

If you want to see your issue fixed, do not report it here, do it on - GitHub.

Re: Validating an upload - ensure no corruption in transit

OK, that's helpful.  Thank you.

7 (edited by PC88 2017-02-23 21:07:15)

Re: Validating an upload - ensure no corruption in transit

Is there an appropriate way to access the path/filename from the upload queue?
This is for hash validation as mentioned in the previous posts.

I am accessing the array of file names as follows:
filenameElement[0] = uploader.files[(filecount)];

I am looking for path/filename.
Suggestions for getting each path/filename in the upload queue are welcome.

I am new to javascript.

Thank you for your help.

Re: Validating an upload - ensure no corruption in transit

Path is only available for files that were drag and dropped with the folder and is relative at all times (and obviously only available for HTML5 runtime). Absolute path is not provided by the environment for security reasons.

One way to access it in your case would be something like this:

uploader.files[0].getSource().relativePath
If you want to see your issue fixed, do not report it here, do it on - GitHub.

Re: Validating an upload - ensure no corruption in transit

Thanks davit,
your response has been helpful.

Re: Validating an upload - ensure no corruption in transit

Hi,
I tried this code: filearray1[0] = uploader.files[0].getSource().relativePath;
The debugger indicates .getsource() is "Undefined" and .relativePath; shows nothing.

Any suggestions?