mirror of
https://github.com/wekan/wekan.git
synced 2025-12-24 03:10:12 +01:00
Store file on filesystem renew's the storage path
This commit is contained in:
parent
9d587e76ab
commit
a064e03fc7
3 changed files with 42 additions and 13 deletions
|
|
@ -6,18 +6,20 @@ import path from 'path';
|
|||
import FileStoreStrategyFactory, { FileStoreStrategyFilesystem, FileStoreStrategyGridFs} from '/models/lib/fileStoreStrategy';
|
||||
|
||||
let avatarsBucket;
|
||||
let storagePath;
|
||||
if (Meteor.isServer) {
|
||||
avatarsBucket = createBucket('avatars');
|
||||
storagePath = path.join(process.env.WRITABLE_PATH, 'avatars');
|
||||
}
|
||||
|
||||
const fileStoreStrategyFactory = new FileStoreStrategyFactory(FileStoreStrategyFilesystem, FileStoreStrategyGridFs, avatarsBucket);
|
||||
const fileStoreStrategyFactory = new FileStoreStrategyFactory(FileStoreStrategyFilesystem, storagePath, FileStoreStrategyGridFs, avatarsBucket);
|
||||
|
||||
Avatars = new FilesCollection({
|
||||
debug: false, // Change to `true` for debugging
|
||||
collectionName: 'avatars',
|
||||
allowClientCode: true,
|
||||
storagePath() {
|
||||
const ret = path.join(process.env.WRITABLE_PATH, 'avatars');
|
||||
const ret = fileStoreStrategyFactory.storagePath;
|
||||
return ret;
|
||||
},
|
||||
onBeforeUpload(file) {
|
||||
|
|
@ -59,7 +61,7 @@ if (Meteor.isServer) {
|
|||
});
|
||||
|
||||
Meteor.startup(() => {
|
||||
const storagePath = Avatars.storagePath();
|
||||
const storagePath = fileStoreStrategyFactory.storagePath;
|
||||
if (!fs.existsSync(storagePath)) {
|
||||
console.log("create storagePath because it doesn't exist: " + storagePath);
|
||||
fs.mkdirSync(storagePath, { recursive: true });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue