chore: remove unused
This commit is contained in:
parent
428c745e32
commit
d09ff6cff1
1 changed files with 0 additions and 34 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue