I have previously used the edgee:slingshot package with success and have pretty much copied the code I used from another project. This code now does not work on this new project. I have updated to Meteor 1.4, I don’t know if this is part of what is causing this issue as this upgrade to 1.4 has also caused me 1,000 other issues in getting back to working on my project.
So I am getting this error when running uploader.send():
underscore.js:113 Uncaught RangeError: Maximum call stack size exceeded
Here’s some of my code if anyone can see something that may be causing this:
client:
...
'change #new-blog-post-image-upload': function ( event, template ) {
let file = $('#new-blog-post-image-upload');
let options = {
event: event,
template: template,
file: file[0].files[0]
};
Modules.uploadBlogImage( options );
...
}
...
let _addUrlToDatabase = ( options, url ) => {
Meteor.call( 'store.blog.image', url, ( error ) => {
if ( error ) {
...
} else {
...
}
});
};
Modules.uploadBlogImage = ( options ) => {
let meta = options;
const uploader = new Slingshot.Upload( 'uploadBlogImage', meta );
uploader.send( options.file, ( error, url ) => {
if ( error ) {
console.log( 'err' );
} else {
console.log( 'success' );
_addUrlToDatabase( options, url );
}
});
}
Server:
Slingshot.fileRestrictions( "uploadBlogImage", {
allowedFileTypes: [ "image/png", "image/jpeg", "image/gif" ],
maxSize: 12 * 1024 * 1024
});
Slingshot.createDirective( "uploadBlogImage", Slingshot.S3Storage, {
bucket: "bucket-name",
acl: "public-read",
authorize: function ( file, meta ) {
return true;
},
key: function ( file, meta ) {
return file.name;
}
});
Methods.js:
...
'store.blog.image': function ( url ) {
console.log('method running');
return BlogMedia.insert({
createdAt: new Date(),
createdBy: Meteor.userId(),
url: url
});
}
...
The slingshot version is the same version as my other projects, 0.7.1. But like I said, I am not 100% sure this error has anything to do with my code or Slingshot…I am thinking something else went wrong when updating Meteor. I can’t seem to find help because the error thrown is really vague.