Error is thrown in the data-man-api.js in the following function:
/**
* @method DataMan.prototype.getBinary
* @public
* @param {Number} [start] - First byte position to read.
* @param {Number} [end] - Last byte position to read.
* @param {Function} callback - callback(error, binaryData)
* @returns {undefined}
*
* Passes a Uint8Array representing this data to a callback.
*/
DataMan.prototype.getBinary = function dataManGetBinary(start, end, callback) {
var self = this;
if (typeof start === "function") {
callback = start;
}
callback = callback || defaultCallback;
function read(blob) {
if (typeof FileReader === "undefined") {
callback(new Error("Browser does not support FileReader"));
return;
}
var reader = new FileReader();
reader.onload = function(evt) {
callback(null, new Uint8Array(evt.target.result));
};
reader.onerror = function(err) {
console.log("error is here: ", err);
callback(err);
};
reader.readAsArrayBuffer(blob);
}
self.getBlob(function (error, blob) {
if (error) {
callback(error);
} else {
if (typeof start === "number" && typeof end === "number") {
var size = blob.size;
// Return the requested chunk of binary data
if (start >= size) {
callback(new Error("DataMan.getBinary: start position beyond end of data (" + size + ")"));
return;
}
end = Math.min(size, end);
var slice = blob.slice || blob.webkitSlice || blob.mozSlice;
if (typeof slice === 'undefined') {
callback(new Error('Browser does not support File.slice'));
return;
}
read(slice.call(blob, start, end, self._type));
} else {
// Return the entire binary data
read(blob);
}
}
});
};
It fails in this part:
reader.onerror = function(err) {
console.log("error is here: ", err);
callback(err);
};
When I log err to the console, I get the following:
{
"total": 0,
"loaded": 0,
"lengthComputable": false,
"path": [],
"cancelBubble": false,
"returnValue": true,
"srcElement": {
"onloadend": null,
"onabort": null,
"onprogress": null,
"onloadstart": null,
"error": {
"code": 1,
"message": "A requested file or directory could not be found at the time an operation was processed.",
"name": "NotFoundError"
},
"result": null,
"readyState": 2
},
"defaultPrevented": false,
"timeStamp": 1442330540332,
"cancelable": true,
"bubbles": false,
"eventPhase": 2,
"currentTarget": {
"onloadend": null,
"onabort": null,
"onprogress": null,
"onloadstart": null,
"error": {
"code": 1,
"message": "A requested file or directory could not be found at the time an operation was processed.",
"name": "NotFoundError"
},
"result": null,
"readyState": 2
},
"target": {
"onloadend": null,
"onabort": null,
"onprogress": null,
"onloadstart": null,
"error": {
"code": 1,
"message": "A requested file or directory could not be found at the time an operation was processed.",
"name": "NotFoundError"
},
"result": null,
"readyState": 2
},
"type": "error"
}
I am on Android 4.1.2. I cannot get this to work. Works fine with ios and browser Tried sending base64, blob and file. Always get this error. @aldeed @raix: Any idea how to resolve this?