feat: minio util func
This commit is contained in:
parent
d0b59a4088
commit
dcfa543479
1 changed files with 12 additions and 0 deletions
|
|
@ -9,3 +9,15 @@ const minio = new Client({
|
||||||
});
|
});
|
||||||
|
|
||||||
export default minio;
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue