Cloud storage and Image manipulation (cross origin problem)

OK, I think I solved all my problems (related to cross origin) and created a package jamgold:cropuploader, which can be seen in action here

1 Like

Thanks much @jamgold

So to summarize it, it uploads the actual files to S3, but maintains thumbnails as mongodb collection at server. Correct?

And when about to crop, what does it do - gets the actual image from S3 and presents the Crop UI?

Then I believe it saves the updated thumbnail just to mongodb server again. Throughout the life time, S3 image does not get modified once written - correct?

It uploads all assets, original and cropped to S3. When you upload an image, it automatically creates a thumbnail derivative. With the crop UI you can create any other type of derivative (like name it avatar) or overwrite the previously generated thumbnail. Up to you.

And yes, the original will never get modified

Cool. Thanks @jamgold

So in essence, client is doing most of the work (like uploading the original, downloading the original for crop, uploading the derivative etc.)

Server is only providing the security (access rights etc…) - right? That’s a nice lean architecture.

@jamgold is there a way to delete the original file in S3 by using your package? thanks :slight_smile:

Yes @seanh, when deleting the record in the collection, the server will delete the derivatives and the original.

1 Like

@jamgold I setup the slingshot config but I got an error when I tried to init the CropUploader in the server side, it said"ReferenceError: Slingshot is not defined". any idea? Thanks

Did you add the slingshot package package? [edit] of course slingshot is being used by the cropuploader package, but only weak. I think you need to add it.

@jamgold yes, I did add the slingshot package before the CropUploader package

Would you mind sharing that lambda script? I’m pretty sure this would be useful for a lot of people since this solution is currently missing for meteor image uploads.

Can you share some code? I am using the package successfully.

my code is essentially based on Amazon’s own example , with a few project-specific modifications (dimensions, bucket names, etc)

Thank you for your help, I uploaded my code to this link. It seems like the code work only if I structure the code in the standard way, but it has error if I structure it into packages based, like the code that I’ve shared :confused:

I see, this seems to have to do with packages scope. I basically add the package to my project and can see the exported objects just fine. Maybe you need to explicitly export Slingshot in your package? I am not quite sure how the package system is supposed to work when having multi-level package imports …

1 Like