I am facing a issue whereby my android users are unable to upload video files from their google drive to the website (when will upload file via input tag, you get the option to retrieve the file from google drive). What i found out so far is that if i send a partial files into readAsArrayBuffer (FileReader API) it wont work, it will only work if i use the whole file.
The reason i am passing a partial files is to handle the case of latency issue. I am using AngularJS. I am unable to share the code as its against my company policy.
UPDATE: Ytd, i ran FileReader.onerror it return this error:
DOMException: The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.`
I am able to upload the files on Firefox and not Chrome.
Thank you
$scope.rewriteVideoFile = function(file, out) {
var totalBytes = 1750000;
return new Promise(function(resolve, reject) {
var reader = new FileReader();
reader.onload = function() {
//Logic here
}
reader.readAsArrayBuffer(file.slice(0, totalBytes));
// reader.readAsArrayBuffer(file); this will work
});
};
function createVideoBlob(file) {
var maxSize = 1550000;
var sendSize = Math.min(maxSize, file.size);
return new Promise(function(resolve, reject) {
if (file.size <= maxSize) {
return resolve(file);
} else if (file.type === 'video/quicktime' || file.type === 'video/mp4') {
var out = [];
scope.rewriteVideoFile(file, out).then(function () {
console.log('rewriteVideoFile .then');
var blob = new Blob(out, {type : 'application/octet-stream'});
return resolve(blob);
});
} else {
return resolve(file.slice(0, sendSize, 'application/octet-stream'));
}
})
}