laren0815
laren0815

Reputation: 263

Meteor upload image blob

I use a ImageCropper (https://www.npmjs.com/package/cropper) and this generated by a cut-out image, the blob object. This Blob Object I would now like to also upload how is this possible?

My current not working approach:

Client:

 $(elem).cropper('getCroppedCanvas').toBlob(function (blob) {
    var file = new File([blob], "name");
    Meteor.call('file-upload', file);
 });

Server:

Meteor.methods({
    'file-upload': function (file) {
        var fs = Meteor.npmRequire('fs');
        fs.writeFile("/tmp/test.jpg", file, function (err) {
            if (err) {
                return console.log(err);
            }

            console.log("The file was saved!");
        });
    }
});

Upvotes: 0

Views: 676

Answers (1)

gkrizek
gkrizek

Reputation: 1086

See my answer in this SO post.

I highly recommend Slingshot. It's really easy to use and uploads blobs.

Upvotes: 0

Related Questions