Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Meteor - S3 file upload + thumbnailing
#
# 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]
)
#
# 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
<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
You can’t perform that action at this time.