Can someone please quickly explain something basic


Ive recently started developing in Meteor or javascript for that matter and im trying to install a package called slingshot.

The tutorial says to put this on the client side.

   var uploader = new Slingshot.Upload("myFileUploads");

uploader.send(document.getElementById('input').files[0], function (error, downloadUrl) {
  if (error) {
    // Log service detailed response.
    console.error('Error uploading', uploader.xhr.response);
    alert (error);
  else {
    Meteor.users.update(Meteor.userId(), {$push: {"profile.files": downloadUrl}});

But where exactly do i put it? Do i need to create a new file altogether?

The same goes for putting this on the server side. Where exactly do i put it?

  Slingshot.createDirective("myFileUploads", Slingshot.S3Storage, {
  bucket: "mybucket",

  acl: "public-read",

  authorize: function () {
    //Deny uploads if user is not logged in.
    if (!this.userId) {
      var message = "Please login before posting files";
      throw new Meteor.Error("Login Required", message);

    return true;

  key: function (file) {
    //Store file into a directory by the user's username.
    var user = Meteor.users.findOne(this.userId);
    return user.username + "/" +;

Thanks in advance.

Meteor is very flexible about the file structure.

You can either put a new file in a client or server directory, put that code in any existing file, or put it somewhere that is loaded on client and server and wrap it in a if (Meteor.isServer) statement.

First problem i seem to hit is if i copy the first block of code is “Unresolved variable or type Slingshot”.

Thats after copying it into a “deal.js” file which is in the client folder. The deal.js is just a file made to match a deals collection it seems.

Thanks for replying.

Have you added the appropriate package to your app with meteor add?

That leads me to another question.

Im using Webstorm and ive copied several packages but only some seem to show up in the “External Libraries” section.

For example aldeed-autoform is there after running the command to install that but after i ran “meteor add edgee:slingshot” i assumed edgee:slingshot would be there but it isnt.

Is there a way to update the packages like Maven or should it even be there?

Sorry, I don’t know what WebStorm does to show you external libraries! You can run meteor list in the terminal to check what packages are in your app, or look at .meteor/packages.

Yeah its definitely there alright. Still missing something.