Ensure to create the upload directory

This commit is contained in:
Martin Filser 2022-02-16 22:20:35 +01:00 committed by Denis Perov
parent 086cb9c067
commit 368fe24956
3 changed files with 26 additions and 2 deletions

View file

@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { FilesCollection } from 'meteor/ostrio:files';
import fs from 'fs';
import path from 'path';
import { createBucket } from './lib/grid/createBucket';
import { createOnAfterUpload } from './lib/fsHooks/createOnAfterUpload';
@ -43,6 +44,14 @@ if (Meteor.isServer) {
remove: isOwner,
fetch: ['userId'],
});
Meteor.startup(() => {
const storagePath = Avatars.storagePath();
if (!fs.existsSync(storagePath)) {
console.log("create storagePath because it doesn't exist: " + storagePath);
fs.mkdirSync(storagePath, { recursive: true });
}
});
}
export default Avatars;