Slingshot S3 Upload from Server

I am successfully using Edgee:Slingshot to upload images from Autoform on the client side to S3.

When trying to upload an image via Restivus API, I need the Slingshot library available on the server side to allow S3 uploads.

The problem is, when I do a POST request to my API endpoint, I get this error:

Exception in callback of async function: TypeError: undefined is not a function which is referring to this bit of code:

var uploader = new Slingshot.Upload(“thumbSmall”);

Can anyone advise on how to make slingshot available on the server as well to make the API work? Thanks in advance!


Hi @darkmattr

According to this, you hava to use some other method, but I can’t find how to do it.

Did you have any luck doing this with slingshot ?

To upload images to S3 from the server, I had to use the Knox npm module.

var knox = Npm.require("knox");
var client = knox.createClient({
    key: Meteor.settings.private.AWSAccessKeyId,
    secret: Meteor.settings.private.AWSSecretAccessKey,
    bucket: Meteor.settings.private.AWSbucket,
    region: Meteor.settings.private.AWSregion
client.putFile(file, filename, {
    'Content-Length': fileSizeBytes,
    'Content-Type': 'image/jpeg',
    'x-amz-acl': 'public-read',
}, function(err, res) {
    if (err) {
    } else {

I had issues with fs.createWriteStream when using a /tmp/ folder and uploading from there, so created a totally separate app/api to just handle file uploads from multipart formdata.

The code above is an incomplete example but can point you in the right direction.

1 Like

That was a quick reply !

Thanks for the code sample @darkmattr, but it seams that the putFile method called in the server generate this error error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.

Did you get this as well ?


var Fiber = Npm.require('fibers');

Wrap the function in:

Fiber(function() {

1 Like

Hi @darkmattr, I’m having some issues with Knox trying to upload a file read on the server to S3. Would you mind sharing a more complete code snippet? Cheers