Hi,
I had this problem before.
The problem is Outsystems can't read the binary data from readAsBinaryString() function. I don't know why . My guess is Binary data and Blob data type are different.
Here is what i did to overcome.
I convert to base64 using readAsDataURL(), File data now is text, chunk it and send it to server then convert back to binary.
Here is my js for upload for your reference.
function readAndSend(file) {
var reader = new FileReader();
reader.addEventListener('load', function() {
var startOfOSBinary = this.result.indexOf(";base64,") + 8;
var lengthOSBinary = this.result.length - startOfOSBinary;
var OSbinary = this.result.substr(startOfOSBinary, lengthOSBinary);
$actions.TriggerFileUpload(file.name, file.size, file.type, OSbinary);
}, false);
reader.readAsDataURL(file);
}
var fileInput = document.getElementById($parameters.FileInputId);
var files = Array.from(fileInput.files);
if (files) {
for (var i = 0; i < files.length; i++) {
readAndSend(files[i]);
}
} else {
$actions.TriggerFileUploadError("", "", "Uploading files is disabled");
}
fileInput.value = "";
I define TriggerFileUpload action for handling the file . OSBinary is a whole file as text, so i chunk it then send to server then convert back to binary.
I used this to upload large image and video too.
Hope it help.
Cheers, Nam