In order to troubleshoot, I try to log md5sum of a binary file.
When I upload a binary file, I perform the following operation:
<div class="modal-body" id="modal-body">
<div class="btn btn-default" ngf-select="upload($files)" ngf-multiple="true">Add File</div>
Drop File:
<div ngf-drop ngf-select ng-model="files" class="drop-box"
ngf-drag-over-class="'dragover'" ngf-multiple="true" ngf-include-dir="true" ngf-allow-dir="true"
>Drag and Drop file</div>
<div ngf-no-file-drop>File Drag/Drop is not supported for this browser</div>
<!-- Files: -->
<!-- <ul> -->
<!-- <li ng-repeat="f in files" style="font:smaller">{{f.name}} {{f.$error}} {{f.$errorParam}}</li> -->
<!-- </ul> -->
Upload Log:
<pre>{{log}}</pre>
Controller ->
$scope.upload = function (files) {
if (files && files.length) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
_manageUpload(file);
...
function _manageUpload(file) {
_getFileContent(f, function(err, data) {
....
}
function _getFileContent(f, cb) {
var reader = new FileReader();
// reader.readAsText(f, "UTF-8");
reader.readAsBinaryString(f);
reader.onload = function (evt) {
var md5Hash = CryptoJS.MD5(evt.target.result);
console.log(md5Hash.toString())
cb(null, evt.target.result);
}
reader.onerror = function (evt) {
cb(new Error("error reading file"));
}
}
}
...
}
The following code outputs md5 of a file:
Anyway, this md5 differs from the original md5sum:
Wrong file is properly saved on server-side (it contains the same md5 of acquired file).
Do you have any suggestion to solve this?
Thanks in advance,
GP
Hi, I am using ng-file library to support upload of files. I have an issue relating to binary files that is described at the following issue: https://github.com/giper45/DockerSecurityPlayground/issues/51
In order to troubleshoot, I try to log md5sum of a binary file. When I upload a binary file, I perform the following operation:
Controller ->
The following code outputs md5 of a file:![image](https://user-images.githubusercontent.com/18548727/87432420-417cbd80-c5e8-11ea-8b46-07d9fa9aac52.png)
Anyway, this md5 differs from the original md5sum:
Wrong file is properly saved on server-side (it contains the same md5 of acquired file).
Do you have any suggestion to solve this? Thanks in advance, GP