Enhance uploadFile to support multiple files and update handleMove to process file paths for moving files

This commit is contained in:
2025-07-12 13:59:30 +02:00
parent 1a7c97fb08
commit 51c6f62c44
3 changed files with 88 additions and 22 deletions

View File

@@ -199,20 +199,24 @@ export const moveFile = async (
};
/**
* uploadFile uploads a file to a workspace
* uploadFile uploads multiple files to a workspace
* @param workspaceName - The name of the workspace
* @param directoryPath - The directory path where the file should be uploaded
* @param file - The file to upload
* @param directoryPath - The directory path where files should be uploaded
* @param files - Multiple files to upload
* @returns {Promise<SaveFileResponse>} A promise that resolves to the upload file response
* @throws {Error} If the API call fails or returns an invalid response
*/
export const uploadFile = async (
workspaceName: string,
directoryPath: string,
file: File
files: FileList
): Promise<SaveFileResponse> => {
const formData = new FormData();
formData.append('file', file);
// Add all files to the form data
Array.from(files).forEach((file) => {
formData.append('file', file);
});
const response = await apiCall(
`${API_BASE_URL}/workspaces/${encodeURIComponent(