🚩 add file assets getter

create helper and boiler controller for get assets from object storage
This commit is contained in:
Rafi Arrafif
2025-07-23 22:17:48 +07:00
parent 95d85545cd
commit f2649c6d92
5 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,11 @@
import { Context } from "elysia";
import { mainErrorHandler } from "../../../helpers/error/handler";
import { getPresignedFileUrl } from "../../../utils/storages/MinIO/operations/getPresignedFileUrl";
export const presignedAssetsController = async (ctx: Context) => {
try {
return await getPresignedFileUrl(ctx.params["*"]);
} catch (error) {
return mainErrorHandler(ctx.set, error);
}
};

View File

@ -0,0 +1,11 @@
import { Context } from "elysia";
import { getStreamFile } from "../../../utils/storages/MinIO/operations/getStreamFile";
import { mainErrorHandler } from "../../../helpers/error/handler";
export const streamAssetsController = async (ctx: Context) => {
try {
return await getStreamFile(ctx.params["*"]);
} catch (error) {
return mainErrorHandler(ctx.set, error);
}
};

View File

@ -0,0 +1,7 @@
import Elysia from "elysia";
import { streamAssetsController } from "./controllers/streamAssets.controller";
import { presignedAssetsController } from "./controllers/presignedAssets.controller";
export const assetsModule = new Elysia({ prefix: "/assets" })
.get("/stream/*", streamAssetsController)
.get("/presigned/*", presignedAssetsController);