|
@@ -1,6 +1,5 @@
|
|
import fs from 'fs';
|
|
import fs from 'fs';
|
|
import { createObjectId } from './grid/createObjectId';
|
|
import { createObjectId } from './grid/createObjectId';
|
|
-import { createOnAfterUpload } from './fsHooks/createOnAfterUpload';
|
|
|
|
import { createInterceptDownload } from './fsHooks/createInterceptDownload';
|
|
import { createInterceptDownload } from './fsHooks/createInterceptDownload';
|
|
import { createOnAfterRemove } from './fsHooks/createOnAfterRemove';
|
|
import { createOnAfterRemove } from './fsHooks/createOnAfterRemove';
|
|
|
|
|
|
@@ -26,7 +25,16 @@ export default class FileStoreStrategyFactory {
|
|
*/
|
|
*/
|
|
getFileStrategy(filesCollection, fileObj, versionName, storage) {
|
|
getFileStrategy(filesCollection, fileObj, versionName, storage) {
|
|
if (!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;
|
|
let ret;
|
|
if (["fs", "gridfs"].includes(storage)) {
|
|
if (["fs", "gridfs"].includes(storage)) {
|
|
@@ -111,12 +119,6 @@ export class FileStoreStrategyGridFs extends FileStoreStrategy {
|
|
this.gridFsBucket = gridFsBucket;
|
|
this.gridFsBucket = gridFsBucket;
|
|
}
|
|
}
|
|
|
|
|
|
- /** after successfull upload */
|
|
|
|
- onAfterUpload() {
|
|
|
|
- createOnAfterUpload(this.filesCollection, this.gridFsBucket, this.fileObj, this.versionName);
|
|
|
|
- super.onAfterUpload();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/** download the file
|
|
/** download the file
|
|
* @param http the current http request
|
|
* @param http the current http request
|
|
*/
|
|
*/
|