diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index 6985499e8..ef35b6c8e 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -32,7 +32,7 @@ import { DatabaseModule } from "@/database/database.module"; JwtModule.register({ global: true }), ModulesModule, ServeStaticModule.forRoot({ - rootPath: join(__dirname, "..", "../public"), + rootPath: join(process.cwd(), "public"), serveRoot: "/public" }), ScheduleModule.forRoot(), diff --git a/backend/src/apps/core/files/upload/upload.service.ts b/backend/src/apps/core/files/upload/upload.service.ts index a8b35bf7d..6bb098f4b 100644 --- a/backend/src/apps/core/files/upload/upload.service.ts +++ b/backend/src/apps/core/files/upload/upload.service.ts @@ -1,4 +1,5 @@ import { createWriteStream, existsSync, mkdirSync, statSync } from "fs"; +import { join } from "path"; import { Injectable } from "@nestjs/common"; @@ -79,7 +80,12 @@ export class UploadCoreFilesService { // Create folders const date = new Date(); - const dirFolder = `public/monthly_${date.getMonth() + 1}_${date.getFullYear()}/${module_name}`; + const dir = join( + "public", + `monthly_${date.getMonth() + 1}_${date.getFullYear()}`, + module_name + ); + const dirFolder = join(process.cwd(), dir); if (!existsSync(dirFolder)) { mkdirSync(dirFolder, { recursive: true }); } @@ -87,14 +93,16 @@ export class UploadCoreFilesService { const saveFiles = await Promise.all( files.map(async file => { const { createReadStream, filename, mimetype } = await file; + const extension = filename.split(".").pop(); + const name = filename.split(".").shift(); const stream = createReadStream(); // Generate file name const currentFileName = `${date.getTime()}_${generateRandomString( 10 - )}_${removeSpecialCharacters(filename)}`; - const url = `${dirFolder}/${currentFileName}`; + )}_${removeSpecialCharacters(name)}.${extension}`; + const url = join(dirFolder, currentFileName); // Save file to file system await new Promise((resolve, reject) => @@ -111,8 +119,8 @@ export class UploadCoreFilesService { module_name, mimetype, name: currentFileName, - dir_folder: dirFolder, - extension: filename.split(".").pop(), + dir_folder: dir, + extension, size: stat.size }; }) diff --git a/backend/src/utils/graphql-upload/processRequest.ts b/backend/src/utils/graphql-upload/processRequest.ts index 82d25aa9a..cb4883e58 100644 --- a/backend/src/utils/graphql-upload/processRequest.ts +++ b/backend/src/utils/graphql-upload/processRequest.ts @@ -1,8 +1,8 @@ import { IncomingMessage, ServerResponse } from "http"; -import * as busboy from "busboy"; +import busboy from "busboy"; import * as createError from "http-errors"; -import * as objectPath from "object-path"; +import objectPath from "object-path"; import Upload, { FileUpload } from "./Upload"; import ignoreStream from "./ignoreStream"; diff --git a/frontend/next.config.js b/frontend/next.config.js index 8a92512f0..9d3425573 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -31,8 +31,8 @@ const config = () => { { hostname: "localhost", port: "8080", - protocol: "http", - pathname: "/public/**" + protocol: "http" + // pathname: "/public/**" }, { hostname: backend.hostname, diff --git a/frontend/themes/1/forum/views/forum/forums/views/[id]/actions/action.tsx b/frontend/themes/1/forum/views/forum/forums/views/[id]/actions/actions.tsx similarity index 100% rename from frontend/themes/1/forum/views/forum/forums/views/[id]/actions/action.tsx rename to frontend/themes/1/forum/views/forum/forums/views/[id]/actions/actions.tsx diff --git a/frontend/themes/1/forum/views/forum/forums/views/[id]/forum-forum-view.tsx b/frontend/themes/1/forum/views/forum/forums/views/[id]/forum-forum-view.tsx index 7bd0b24e8..5dfdc03ac 100644 --- a/frontend/themes/1/forum/views/forum/forums/views/[id]/forum-forum-view.tsx +++ b/frontend/themes/1/forum/views/forum/forums/views/[id]/forum-forum-view.tsx @@ -2,7 +2,7 @@ import { useTranslations } from "next-intl"; import { Card, CardContent, CardHeader } from "@/components/ui/card"; import { useTextLang } from "@/hooks/core/use-text-lang"; -import { ActionsForumsForum } from "./actions/action"; +import { ActionsForumsForum } from "./actions/actions"; import type { Forum_Forums__Show_ItemQuery } from "@/graphql/hooks"; import { TopicsListForum } from "./topics-list/topics-list"; import { ReadOnlyEditor } from "@/components/editor/read-only/read-only-editor";