Skip to content
Snippets Groups Projects
Commit ebe28110 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Add GridFS as default avatar storage

parent c1f047df
No related branches found
No related tags found
No related merge requests found
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment