diff options
author | Lauri Ojansivu <x@xet7.org> | 2019-08-08 23:43:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-08 23:43:39 +0300 |
commit | 520ae551c643885d0d5b8ba39cd8de0119f6ef11 (patch) | |
tree | dc4df60552432fbc5d531802b64bc734c3a97f6b /models/attachments.js | |
parent | d5d75ae7b8be606b6253afaf0b5bfebbbe7d8131 (diff) | |
parent | 13a13e8eca67eea4bc8a44dad8a0de52035154ba (diff) | |
download | wekan-520ae551c643885d0d5b8ba39cd8de0119f6ef11.tar.gz wekan-520ae551c643885d0d5b8ba39cd8de0119f6ef11.tar.bz2 wekan-520ae551c643885d0d5b8ba39cd8de0119f6ef11.zip |
Merge pull request #2603 from whowillcare/master
Add Features: allowing wekan master to set where the attachments stor…
Diffstat (limited to 'models/attachments.js')
-rw-r--r-- | models/attachments.js | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/models/attachments.js b/models/attachments.js index 0616c79f..95265422 100644 --- a/models/attachments.js +++ b/models/attachments.js @@ -1,8 +1,23 @@ -Attachments = new FS.Collection('attachments', { - stores: [ - // XXX Add a new store for cover thumbnails so we don't load big images in - // the general board view - new FS.Store.GridFS('attachments', { +const localFSStore = process.env.ATTACHMENTS_STORE_PATH; +const storeName = 'attachments'; +const defaultStoreOptions = { + beforeWrite: fileObj => { + if (!fileObj.isImage()) { + return { + type: 'application/octet-stream', + }; + } + return {}; + }, +}; +const Store = localFSStore + ? new FS.Store.FileSystem(storeName, { + path: localFSStore, + ...defaultStoreOptions, + }) + : new FS.Store.GridFS(storeName, { + // XXX Add a new store for cover thumbnails so we don't load big images in + // the general board view // If the uploaded document is not an image we need to enforce browser // download instead of execution. This is particularly important for HTML // files that the browser will just execute if we don't serve them with the @@ -12,16 +27,10 @@ Attachments = new FS.Collection('attachments', { // XXX Should we use `beforeWrite` option of CollectionFS instead of // collection-hooks? // We should use `beforeWrite`. - beforeWrite: fileObj => { - if (!fileObj.isImage()) { - return { - type: 'application/octet-stream', - }; - } - return {}; - }, - }), - ], + ...defaultStoreOptions, + }); +Attachments = new FS.Collection('attachments', { + stores: [Store], }); if (Meteor.isServer) { |