Slingshot: how to upload from a URL?

256 Views Asked by At

I want to upload a file from a URL to S3 using meteor-slingshot.

The docs are clear how to upload from a <input type="file">, but how to get it from a URL? It would look something like this (but obviously this doesn't work):

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

uploader.send("http:/example.com/photo.jpg", 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}});
  }
});

I am guessing it needs a File object, which apparently you can't create. Using AJAX to create a Blob?

I know that CollectionFS can accept a URL, but I want to use slingshot. Thanks.

0

There are 0 best solutions below