added dev docker file
This commit is contained in:
@@ -30,6 +30,7 @@ export default {
|
||||
tempVideoThumbnailLimit: process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
|
||||
? +process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
|
||||
: 0,
|
||||
docker: process.env.DOCKER === "true",
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
@@ -64,4 +65,5 @@ module.exports = {
|
||||
tempVideoThumbnailLimit: process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
|
||||
? +process.env.TEMP_VIDEO_THUMBNAIL_LIMIT
|
||||
: 0,
|
||||
docker: process.env.DOCKER === "true",
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ import fs from "fs";
|
||||
import { UserInterface } from "../../../models/user-model";
|
||||
import { GenericParams, IStorageActions } from "../store-types";
|
||||
import env from "../../../enviroment/env";
|
||||
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
|
||||
|
||||
class FilesystemActions implements IStorageActions {
|
||||
async getAuth() {
|
||||
@@ -60,7 +61,7 @@ class FilesystemActions implements IStorageActions {
|
||||
stream: NodeJS.ReadableStream,
|
||||
randomID: string
|
||||
) => {
|
||||
const path = `${env.fsDirectory}${randomID}`;
|
||||
const path = `${getFSStoragePath()}${randomID}`;
|
||||
return {
|
||||
writeStream: fs.createWriteStream(path),
|
||||
emitter: null,
|
||||
|
||||
@@ -11,6 +11,7 @@ import { FilesystemActions } from "../actions/file-system-actions";
|
||||
import { EventEmitter } from "stream";
|
||||
import FileDB from "../../../db/mongoDB/fileDB";
|
||||
import { getStorageActions } from "../actions/helper-actions";
|
||||
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
|
||||
|
||||
const fileDB = new FileDB();
|
||||
|
||||
@@ -58,7 +59,7 @@ const processData = (
|
||||
name: filename,
|
||||
owner: user._id,
|
||||
IV: thumbnailIV,
|
||||
path: env.fsDirectory + thumbnailFilename,
|
||||
path: getFSStoragePath() + thumbnailFilename,
|
||||
s3ID: thumbnailFilename,
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import { S3Actions } from "../actions/S3-actions";
|
||||
import { FilesystemActions } from "../actions/file-system-actions";
|
||||
import { createGenericParams } from "./storageHelper";
|
||||
import { getStorageActions } from "../actions/helper-actions";
|
||||
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
|
||||
|
||||
const storageActions = getStorageActions();
|
||||
|
||||
@@ -24,7 +25,7 @@ const attemptToRemoveChunks = async (
|
||||
) => {
|
||||
try {
|
||||
const readStreamParams = createGenericParams({
|
||||
filePath: env.fsDirectory + thumbnailFilename,
|
||||
filePath: getFSStoragePath() + thumbnailFilename,
|
||||
Key: thumbnailFilename,
|
||||
});
|
||||
await storageActions.removeChunks(readStreamParams);
|
||||
@@ -98,7 +99,7 @@ const createVideoThumbnail = (
|
||||
name: filename,
|
||||
owner: user._id,
|
||||
IV: thumbnailIV,
|
||||
path: env.fsDirectory + thumbnailFilename,
|
||||
path: getFSStoragePath() + thumbnailFilename,
|
||||
s3ID: thumbnailFilename,
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import videoChecker from "../../../utils/videoChecker";
|
||||
import createVideoThumbnail from "./createVideoThumbnail";
|
||||
import createThumbnail from "./createImageThumbnail";
|
||||
import { RequestTypeFullUser } from "../../../controllers/file-controller";
|
||||
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
|
||||
|
||||
// TODO: We should stop using moongoose directly here,
|
||||
// Also in our fileDB make sure we are actually using File instead
|
||||
@@ -115,7 +116,7 @@ const processData = (
|
||||
} as FileMetadateInterface;
|
||||
|
||||
if (env.dbType === "fs") {
|
||||
metadata.filePath = env.fsDirectory + randomFilenameID;
|
||||
metadata.filePath = getFSStoragePath() + randomFilenameID;
|
||||
} else {
|
||||
metadata.s3ID = randomFilenameID;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import createThumbnail from "./createImageThumbnail";
|
||||
import { EventEmitter } from "events";
|
||||
import { getStorageActions } from "../actions/helper-actions";
|
||||
import { RequestTypeFullUser } from "../../../controllers/file-controller";
|
||||
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
|
||||
|
||||
type FileDataType = {
|
||||
name: string;
|
||||
@@ -133,7 +134,7 @@ const processData = (
|
||||
} as FileMetadateInterface;
|
||||
|
||||
if (env.dbType === "fs") {
|
||||
metadata.filePath = env.fsDirectory + randomFilenameID;
|
||||
metadata.filePath = getFSStoragePath() + randomFilenameID;
|
||||
} else {
|
||||
metadata.s3ID = randomFilenameID;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import env from "../../../enviroment/env";
|
||||
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
|
||||
|
||||
type GenericParmasType = {
|
||||
filePath?: string;
|
||||
@@ -13,11 +14,11 @@ export const createGenericParams = ({ filePath, Key }: GenericParmasType) => {
|
||||
const filePathSplit = filePath!.split("/");
|
||||
const fileName = filePathSplit[filePathSplit.length - 1];
|
||||
return {
|
||||
filePath: env.fsDirectory + fileName,
|
||||
filePath: getFSStoragePath() + fileName,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
filePath: env.fsDirectory + Key!,
|
||||
filePath: getFSStoragePath() + Key!,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -14,6 +14,7 @@ import { S3Actions } from "../actions/S3-actions";
|
||||
import { FilesystemActions } from "../actions/file-system-actions";
|
||||
import { createGenericParams } from "./storageHelper";
|
||||
import { getStorageActions } from "../actions/helper-actions";
|
||||
import { getFSStoragePath } from "../../../utils/getFSStoragePath";
|
||||
|
||||
const storageActions = getStorageActions();
|
||||
|
||||
@@ -73,7 +74,7 @@ const tempCreateVideoThumbnail = (
|
||||
name: filename,
|
||||
owner: user._id,
|
||||
IV: thumbnailIV,
|
||||
path: env.fsDirectory + thumbnailFilename,
|
||||
path: getFSStoragePath() + thumbnailFilename,
|
||||
s3ID: thumbnailFilename,
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import env from "../enviroment/env";
|
||||
|
||||
export const getFSStoragePath = () => {
|
||||
if (env.docker) {
|
||||
return "/data/";
|
||||
} else {
|
||||
return env.fsDirectory;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user