|
|
|
|
@ -1,12 +1,29 @@ |
|
|
|
|
uploadPath = "/var/www/rocket.chat/uploads" |
|
|
|
|
storeType = 'GridFS' |
|
|
|
|
if Meteor.settings?.public?.avatarStore?.type? |
|
|
|
|
storeType = Meteor.settings.public.avatarStore.type |
|
|
|
|
|
|
|
|
|
store = new FS.Store.FileSystem "avatars", |
|
|
|
|
path: uploadPath |
|
|
|
|
fileKeyMaker: (fileObj) -> |
|
|
|
|
filename = fileObj.name() |
|
|
|
|
filenameInStore = fileObj.name({store: 'avatars'}) |
|
|
|
|
store = undefined |
|
|
|
|
|
|
|
|
|
return filenameInStore || filename |
|
|
|
|
beforeWrite = (fileObj) -> |
|
|
|
|
fileObj._setInfo 'avatars', 'storeType', storeType, true |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
fileKeyMaker: (fileObj) -> |
|
|
|
|
filename = fileObj.name() |
|
|
|
|
filenameInStore = fileObj.name({store: 'avatars'}) |
|
|
|
|
|
|
|
|
|
return filenameInStore || filename |
|
|
|
|
else |
|
|
|
|
store = new FS.Store.GridFS "avatars", |
|
|
|
|
beforeWrite: beforeWrite |
|
|
|
|
|
|
|
|
|
@Avatars = new FS.Collection "avatars", |
|
|
|
|
stores: [store] |
|
|
|
|
@ -29,7 +46,7 @@ Meteor.startup -> |
|
|
|
|
|
|
|
|
|
collection = FS._collections['avatars'] |
|
|
|
|
|
|
|
|
|
file = if collection? then collection.findOne({ "copies.avatars.key": opts.filename }) else null |
|
|
|
|
file = if collection? then collection.findOne({ "copies.avatars.name": opts.filename, "copies.avatars.storeType": storeType }) else null |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
collection: collection |
|
|
|
|
|