import { request } from "@/components/service/index";

import { saveBlob, filenameFromContentDisposition } from "@/utils/download";
export const MinioService = {
  async download(objectName: string) {
    const res = await request.getFile("/api/minio/download", {
      objectName,
      type: "type2",
    });

    const blob: Blob = res.data;
    const cd = res.headers?.["content-disposition"];
    const fallback = objectName.split("/").pop() || "download.bin";
    const filename = filenameFromContentDisposition(cd, fallback);

    saveBlob(blob, filename);
  },
};
