[Solved] Error: "Queue" [undefined], Error: [undefined] using CollectionFS/GridFS on Android

I am getting the following error only on Android when saving a blob from the camera using CollectionFS with GridFs. I am using METEOR@1.2-rc.11 with cordova/crosswalks. I dont know what could be the reason, how to debug and resolve this. Any hints much appreciated!

[INFO:CONSOLE(173)] "Error: "Queue" [undefined], Error: [undefined]
     at o (http://meteor.local/293e307d89ca8f9b0ac22847c98fd49c582f76c2.js?meteor_js_resource=true:296:3378)
     at FileReader.n.getBinary.t.onerror (http://meteor.local/293e307d89ca8f9b0ac22847c98fd49c582f76c2.js?meteor_js_resource=true:278:4311)", source: http://meteor.local/plugins/cordova-plugin-console/www/console-via-logger.js (173)

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?

so it seems it when converting the blob to a file, the fileReader throws an NOT_FOUND_ERR. How can it be that this only happens on Android?

okay, I am now sure this is caused by the update to RC1.2 (from 1.1.0.3). Does happen only on Android (tested 4 and 5 in Emulator and on Device). Using RC15 now but also tested RC7 and RC12. @martijnwalraven do you have any idea what causes this? I think that will impact all people using collectionFS and Android.

set up a minimal reproduction that shows the problem (only occurs on Android): https://github.com/miri-am/fsTest

@miriam7 can you try a minimal reproduction that does not use CollectionFS? It sounds like there is some issue with the file path or maybe with files being included in the android build. Just try with the FileReader code directly and maybe you can come up with a more basic reproduction that will allow MDG to fix the issue.

Thaks @aldeed. You are right: collectionFS is not the problem. Posted a simple reproduction with a fileReader and opened the issue here: https://github.com/meteor/meteor/issues/5202

Since I’ve upgraded to Meteor 1.2, I can’t store anymore “base64:data/jpeg” strings to my collection. In Meteor 1.1 it worked fine. The file gets added to the collection, but I can’t display it anymore, isUploaded() returns always false.

I’m using it with Cordova.

solved by @martijnwalraven https://github.com/meteor/meteor/issues/5202.

Quoting his answer::

This took a while to figure out, but it turns out this is a bug in Cordova Android. It should be fixed in a new Cordova release. Fortunately, there is an easy workaround. Just add this to your mobile-config.js:

App.accessRule("blob:*");

1 Like