Add support for copying a file or folder
This commit is contained in:
parent
3970a24218
commit
5aa40800c8
8 changed files with 119 additions and 16 deletions
19
resources/assets/scripts/api/server/files/copyElement.ts
Normal file
19
resources/assets/scripts/api/server/files/copyElement.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import {withCredentials} from "@/api/http";
|
||||
import {ServerApplicationCredentials} from "@/store/types";
|
||||
|
||||
/**
|
||||
* Creates a copy of the given file or directory on the Daemon. Expects a fully resolved path
|
||||
* to be passed through for both data arguments.
|
||||
*/
|
||||
export function copyElement(server: string, credentials: ServerApplicationCredentials, data: {
|
||||
currentPath: string, newPath: string
|
||||
}): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
withCredentials(server, credentials).post('/v1/server/file/copy', {
|
||||
from: data.currentPath,
|
||||
to: data.newPath,
|
||||
})
|
||||
.then(() => resolve())
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
|
@ -5,10 +5,10 @@ import {ServerApplicationCredentials} from "@/store/types";
|
|||
* Deletes files and/or folders from the server. You should pass through an array of
|
||||
* file or folder paths to be deleted.
|
||||
*/
|
||||
export function deleteElement(server: string, credentials: ServerApplicationCredentials, items: Array<string>): Promise<any> {
|
||||
export function deleteElement(server: string, credentials: ServerApplicationCredentials, items: Array<string>): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
withCredentials(server, credentials).post('/v1/server/file/delete', { items })
|
||||
.then(resolve)
|
||||
.then(() => resolve())
|
||||
.catch(reject);
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue