chore: remove unused

This commit is contained in:
Methapon Metanipat 2024-10-22 09:28:26 +07:00
parent 428c745e32
commit d09ff6cff1

View file

@ -10,28 +10,6 @@ const minio = new Client({
export default minio;
export async function deleteFolder(bucket: string, path: string, wait = false) {
return new Promise<string[]>((resolve, reject) => {
const item: string[] = [];
const stream = minio.listObjectsV2(bucket, path);
stream.on("data", (v) => v && v.name && item.push(v.name));
stream.on("end", () => resolve(item));
stream.on("error", () => reject(new Error("MinIO error.")));
}).then(async (list) => {
const promises = list.map(async (v) =>
minio.removeObject(bucket, v, {
forceDelete: true,
}),
);
if (wait) await Promise.allSettled(promises);
return list;
});
}
// minio typescript does not support include version
type BucketItemWithVersion = {
name: string;
@ -70,15 +48,3 @@ export async function deleteObjectAllVersion(bucket: string, obj: string) {
resolve(true);
});
}
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;
}