Add support for actually creating that folder on the daemon
This commit is contained in:
parent
0b11532a48
commit
866b3a3aac
4 changed files with 62 additions and 10 deletions
27
resources/assets/scripts/api/server/files/createFolder.ts
Normal file
27
resources/assets/scripts/api/server/files/createFolder.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import {ServerApplicationCredentials} from "@/store/types";
|
||||
import http from "@/api/http";
|
||||
import {AxiosError, AxiosRequestConfig} from "axios";
|
||||
import {ServerData} from "@/models/server";
|
||||
|
||||
/**
|
||||
* Connects to the remote daemon and creates a new folder on the server.
|
||||
*/
|
||||
export function createFolder(server: ServerData, credentials: ServerApplicationCredentials, path: string): Promise<void> {
|
||||
const config: AxiosRequestConfig = {
|
||||
baseURL: credentials.node,
|
||||
headers: {
|
||||
'X-Access-Server': server.uuid,
|
||||
'X-Access-Token': credentials.key,
|
||||
},
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post('/v1/server/file/folder', { path }, config)
|
||||
.then(() => {
|
||||
resolve();
|
||||
})
|
||||
.catch((error: AxiosError) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue