🚩 add file assets getter
create helper and boiler controller for get assets from object storage
This commit is contained in:
15
src/utils/storages/MinIO/operations/getPresignedFileUrl.ts
Normal file
15
src/utils/storages/MinIO/operations/getPresignedFileUrl.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { minioClient } from "../client";
|
||||
import { ensureBucketExists } from "../validations/ensureBucketExists";
|
||||
|
||||
export const getPresignedFileUrl = async (
|
||||
filename: string,
|
||||
expiresInSeconds: number = 3200
|
||||
) => {
|
||||
await ensureBucketExists();
|
||||
|
||||
return await minioClient.presignedGetObject(
|
||||
process.env.MINIO_BUCKET!,
|
||||
filename,
|
||||
expiresInSeconds
|
||||
);
|
||||
};
|
||||
8
src/utils/storages/MinIO/operations/getStreamFile.ts
Normal file
8
src/utils/storages/MinIO/operations/getStreamFile.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { minioBucketName, minioClient } from "../client";
|
||||
import { ensureBucketExists } from "../validations/ensureBucketExists";
|
||||
|
||||
export const getStreamFile = async (filename: string) => {
|
||||
await ensureBucketExists();
|
||||
|
||||
return await minioClient.getObject(process.env.MINIO_BUCKET!, filename);
|
||||
};
|
||||
Reference in New Issue
Block a user