Meteor and S3: How to define three different images by one upload/editing

127 Views Asked by At

I'm using edgee:slingshot for uploading images to S3. This is working well. But I would like to have three different images - I would call them 'stores'. One store for thumbnails, one store for the original image and one store for a cropped public version.

But I don't know how I should do that in a smart way.

Of course I could do three different Slingshot.Upload() on three buckets. But I think it would be smarter to do just one upload, process the files (cropping by graphicsmagick) and store three different files.

Later I want to edit the public file and create a new thumbnail at the same time.

client.js

Template.uploader.events({
    'change .uploadFile': function(event, template) {
        event.preventDefault();

        var upload = new Slingshot.Upload("directiveUpload");
    }
});

server.js

Slingshot.createDirective("directiveUpload", Slingshot.S3Storage, {
    AWSAccessKeyId: "keyid",
    AWSSecretAccessKey: "accesskey",
    bucket: "video",
    acl: "public-read",
});

shared.js

Images = new Mongo.Collection('images');
1

There are 1 best solutions below

0
On

One obvious solution would be to leverage AWS Lambda to process the image files once uploaded to an s3 bucket.

Amazon actually has a tutorial on how to do exactly what you are talking about using Amazon S3 and Lambda.

Check it out: Tutorial: Using AWS Lambda with Amazon S3