removed createOnAfterUpload file and use existing code for initial file move to GridFS

This commit is contained in:
Martin Filser 2022-04-03 23:44:02 +02:00
parent fe018225b4
commit 9ef45a75af
4 changed files with 18 additions and 53 deletions

View file

@ -1,6 +1,5 @@
import fs from 'fs';
import { createObjectId } from './grid/createObjectId';
import { createOnAfterUpload } from './fsHooks/createOnAfterUpload';
import { createInterceptDownload } from './fsHooks/createInterceptDownload';
import { createOnAfterRemove } from './fsHooks/createOnAfterRemove';
@ -26,7 +25,16 @@ export default class FileStoreStrategyFactory {
*/
getFileStrategy(filesCollection, fileObj, versionName, storage) {
if (!storage) {
storage = fileObj.versions[versionName].storage || "gridfs";
storage = fileObj.versions[versionName].storage;
if (!storage) {
if (fileObj.meta.source == "import") {
// uploaded by import, so it's in GridFS (MongoDB)
storage = "gridfs";
} else {
// newly uploaded, so it's at the filesystem
storage = "fs";
}
}
}
let ret;
if (["fs", "gridfs"].includes(storage)) {
@ -111,12 +119,6 @@ export class FileStoreStrategyGridFs extends FileStoreStrategy {
this.gridFsBucket = gridFsBucket;
}
/** after successfull upload */
onAfterUpload() {
createOnAfterUpload(this.filesCollection, this.gridFsBucket, this.fileObj, this.versionName);
super.onAfterUpload();
}
/** download the file
* @param http the current http request
*/