update
This commit is contained in:
@@ -77,5 +77,29 @@ export default function files(pterodactyl: any) {
|
||||
console.error("Error fetching data:", error);
|
||||
}
|
||||
},
|
||||
|
||||
async saveContent(filename: string, content: string) {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_URL}/api/client/servers/${pterodactyl.server_id}/files/write?file=${filename}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: await pterodactyl.helpers.authHeader("application/text"),
|
||||
body: "'test'",
|
||||
}
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching data:", error);
|
||||
}
|
||||
},
|
||||
|
||||
async createFile(filename: string) {
|
||||
this.saveContent(filename, "");
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user