Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ http
cfs:filesystem
cfs:standard-packages
cfs:gridfs
cfs:graphicsmagick
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ cfs:collection-filters@0.2.4
cfs:data-man@0.0.6
cfs:file@0.1.17
cfs:filesystem@0.1.2
cfs:graphicsmagick@0.0.18
cfs:gridfs@0.0.33
cfs:http-methods@0.0.29
cfs:http-publish@0.0.13
Expand Down
14 changes: 13 additions & 1 deletion lib/file.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@ store = undefined
beforeWrite = (fileObj) ->
fileObj._setInfo 'avatars', 'storeType', storeType, true

transformWrite = (fileObj, readStream, writeStream) ->
if Meteor.settings?.public?.avatarStore?.size?.height?
height = Meteor.settings.public.avatarStore.size.height
width = Meteor.settings.public.avatarStore.size.width
gm(readStream, fileObj.name()).resize(height, width).stream().pipe(writeStream)
else
readStream.pipe(writeStream)

if storeType is 'FileSystem'
path = "~/uploads"
if Meteor.settings?.public?.avatarStore?.path?
path = Meteor.settings.public.avatarStore.path
console.log path

store = new FS.Store.FileSystem "avatars",
path: path
beforeWrite: beforeWrite
transformWrite: transformWrite
fileKeyMaker: (fileObj) ->
filename = fileObj.name()
filenameInStore = fileObj.name({store: 'avatars'})
Expand All @@ -24,9 +32,13 @@ if storeType is 'FileSystem'
else
store = new FS.Store.GridFS "avatars",
beforeWrite: beforeWrite
transformWrite: transformWrite

@Avatars = new FS.Collection "avatars",
stores: [store]
filter:
allow:
contentTypes: ['image/*']

@Avatars.allow
insert: ->
Expand Down