feat: minio util func

This commit is contained in:
Methapon2001 2024-06-09 11:18:02 +07:00
parent d0b59a4088
commit dcfa543479

View file

@ -9,3 +9,15 @@ const minio = new Client({
});
export default minio;
export async function presignedGetObjectIfExist(bucket: string, obj: string, exp?: number) {
if (
await minio.statObject(bucket, obj).catch((e) => {
if (e.code === "NotFound") return false;
throw new Error("Object storage error.");
})
) {
return await minio.presignedGetObject(bucket, obj, exp);
}
return null;
}