copy files
This commit is contained in:
@@ -335,3 +335,38 @@ export async function moveFile(
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
|
||||
export async function copyFile(
|
||||
warrenId: string,
|
||||
currentPath: string,
|
||||
targetPath: string
|
||||
): Promise<{ success: boolean }> {
|
||||
const { status } = await useFetch(getApiUrl(`warrens/files/cp`), {
|
||||
method: 'POST',
|
||||
headers: getApiHeaders(),
|
||||
body: JSON.stringify({
|
||||
warrenId,
|
||||
path: currentPath,
|
||||
targetPath: targetPath,
|
||||
}),
|
||||
});
|
||||
|
||||
if (status.value !== 'success') {
|
||||
toast.error('Copy', {
|
||||
id: 'COPY_FILE_TOAST',
|
||||
description: `Failed to copy file`,
|
||||
});
|
||||
return { success: false };
|
||||
}
|
||||
|
||||
await refreshNuxtData('current-directory');
|
||||
|
||||
toast.success('Copy', {
|
||||
id: 'COPY_FILE_TOAST',
|
||||
description: `Successfully copied file`,
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user