Meteor-CollectionFS
Meteor-CollectionFS copied to clipboard
gridFsUpload "Cannot read property '2' of null"
Hi,
I need some help troubleshooting this server-side error:
Exception while invoking method 'gridFsUpload' TypeError: Cannot read property '2' of null
at DataManBuffer.DataManDataURI (packages/cfs_data-man/packages/cfs_data-man.js:312:1)
at new DataMan (packages/cfs_data-man/packages/cfs_data-man.js:64:1)
at setData (packages/cfs_file/packages/cfs_file.js:107:1)
at EventEmitter.fsFileAttachData [as attachData] (packages/cfs_file/packages/cfs_file.js:102:1)
at EventEmitter.FS.File (packages/cfs_file/packages/cfs_file.js:25:1)
at EventEmitter.FS.Collection.insert (packages/cfs_collection/packages/cfs_collection.js:267:1)
at [object Object].Meteor.methods.gridFsUpload (server/methods.js:9:1)
at maybeAuditArgumentChecks (livedata_server.js:1692:12)
at livedata_server.js:708:19
at [object Object]._.extend.withValue (packages/meteor/packages/meteor.js:1013:1)
Seeing the easy-security package is deprecated, I then removed it, but the error remained:
Exception while invoking method 'gridFsUpload' TypeError: Cannot read property '2' of null
at DataManBuffer.DataManDataURI (packages/cfs_data-man/packages/cfs_data-man.js:312:1)
at new DataMan (packages/cfs_data-man/packages/cfs_data-man.js:64:1)
at setData (packages/cfs_file/packages/cfs_file.js:107:1)
at EventEmitter.fsFileAttachData [as attachData] (packages/cfs_file/packages/cfs_file.js:102:1)
at EventEmitter.FS.File (packages/cfs_file/packages/cfs_file.js:25:1)
at EventEmitter.FS.Collection.insert (packages/cfs_collection/packages/cfs_collection.js:267:1)
at [object Object].Meteor.methods.gridFsUpload (server/methods.js:9:1)
at maybeAuditArgumentChecks (livedata_server.js:1692:12)
at livedata_server.js:708:19
at [object Object]._.extend.withValue (packages/meteor/packages/meteor.js:1013:1)
Strange thing is, this only happens on mobile, not on desktop. Maybe I'm missing something with regards to async properties of gridFS? My server method:
'gridFsUpload' : function(imgSrc, post_id) {
var url = '';
var imgInsert = Images.insert(imgSrc, function (err, fileObj) {
if (err){
// handle error
} else {
// handle success depending what you need to do
var insertedPost = Posts.find(post_id).fetch();
local = insertedPost["0"].uploadSrc;
local.push("/cfs/files/images/" + fileObj._id);
var imagesURL = {
"uploadSrc": local
};
var updateResult = Posts.update(post_id, {$set: imagesURL});
url = fileObj._id;
return fileObj._id;
}
});
return imgInsert;
},
Thanks!
Did you solve this? I'm having the same problem...