0

I read online that it is possible to upload a blob string to aws using meteor-slingshot. Only problem is, whenever i pass the blob to the uploader i get a edgee_slingshot.js:283 Uncaught Error: Not a file.

I am getting this object from my cropper:

{
    width: 300, 
    height: 168, 
    type: "png", 
    string: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAokEjHVW7m2KLDU//lU/Of7KFtKzGCDnwAAAAASUVORK5CYII="
}

Then I extract the string as my blob:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAS.....CDnwAAAAASUVORK5CYII=

Then the uploader:

let uploader = new Slingshot.Upload("example");
uploader.send(blob, function(error, url) {
    if (error) {
        console.log(error, "An error happened during the upload.");
    }
    if (!error) {
        console.log("success, here is the url: ", url);
    }
});

Through the console i can see the error is being thrown from:

send: function (file, callback) {                                           // 88
  if (! (file instanceof window.File) && ! (file instanceof window.Blob))   // 89
    throw new Error("Not a file");
Ally Jr
  • 1,055
  • 1
  • 14
  • 27
  • 1
    A "blob string" doesn't exists. Have a look at [Blob](https://developer.mozilla.org/en/docs/Web/API/Blob). What you will need is to convert gour dataURI version to a blob, numerous posts in here already tell you how to do so, [e.g this one](http://stackoverflow.com/questions/4998908/convert-data-uri-to-file-then-append-to-formdata/5100158#5100158) – Kaiido Jul 17 '16 at 23:14
  • @Kaiido thanks a lot! Worked like a charm. I know where i went wrong, I confused the data URI for a blob. – Ally Jr Jul 18 '16 at 08:10

0 Answers0