Created
November 12, 2014 14:10
-
-
Save onepixelsolid/3890f7e1be1a76d316a5 to your computer and use it in GitHub Desktop.
Meteor - S3 file upload + thumbnailing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# FS Collection | |
# | |
profileThumbsStore = new FS.Store.S3('thumb', | |
accessKeyId : 'XXXXXXXXXXXXXXXXXX' | |
secretAccessKey : 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
bucket : 'my-bucket-name' | |
folder : 'thumb' | |
transformWrite : (fileObj, readStream, writeStream) -> | |
gm(readStream, fileObj.name()).resize("100", "100").stream().pipe writeStream | |
return | |
) | |
profileStore = new FS.Store.S3('original', | |
accessKeyId : 'XXXXXXXXXXXXXXXXXX' | |
secretAccessKey : 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
bucket : 'my-bucket-name' | |
folder : 'original' | |
) | |
@Images = new FS.Collection('profiles', | |
stores: [profileStore, profileThumbsStore] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Template Events | |
# | |
Template.my_template.events | |
'change .profile-image': (event, template) -> | |
files = event.target.files | |
i = 0 | |
ln = files.length | |
while i < ln | |
Images.insert files[i], (err, fileObj) -> | |
console.log fileObj | |
i++ | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template name="my_template"> | |
<input type="file" class="profile-image"> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment