started zip download changes

This commit is contained in:
subnub
2024-11-05 21:25:38 -05:00
parent 29a4a8027b
commit 43151731f4
9 changed files with 284 additions and 19 deletions
+26
View File
@@ -1,5 +1,6 @@
import { QueryFunctionContext } from "react-query";
import axios from "../axiosInterceptor";
import { getUserToken } from "./user";
interface QueryKeyParams {
parent: string;
@@ -61,6 +62,31 @@ export const getMoveFolderListAPI = async ({
return response.data;
};
export const downloadZIPAPI = async (
folderIDs: string[],
fileIDs: string[]
) => {
await getUserToken();
// TODO: Change this
let url = `http://localhost:5173/api/folder-service/download-zip?`;
for (const folderID of folderIDs) {
url += `folderIDs[]=${folderID}&`;
}
for (const fileID of fileIDs) {
url += `fileIDs[]=${fileID}&`;
}
const link = document.createElement("a");
document.body.appendChild(link);
link.href = url;
link.setAttribute("type", "hidden");
link.setAttribute("download", "true");
link.click();
};
// POST
export const createFolderAPI = async (name: string, parent?: string) => {