Skip to content

Commit 2faaeae

Browse files
committed
chore: add write request to kdmod
1 parent e9ee319 commit 2faaeae

File tree

1 file changed

+22
-0
lines changed
  • mods/mods_available/kdmod/gui

1 file changed

+22
-0
lines changed

mods/mods_available/kdmod/gui/main.js

+22
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,28 @@ const request_examples = [
7474
const resp = await this.fetch(...a);
7575
return await this.out(resp);
7676
},
77+
},
78+
{
79+
name: 'write file',
80+
fetch: async (path, str) => {
81+
const endpoint = `${window.api_origin}/write`;
82+
const token = puter.authToken;
83+
84+
const blob = new Blob([str], { type: 'text/plain' });
85+
const formData = new FormData();
86+
formData.append('create_missing_ancestors', true);
87+
formData.append('path', path);
88+
formData.append('size', 8);
89+
formData.append('overwrite', true);
90+
formData.append('file', blob, 'something.txt');
91+
92+
const response = await fetch(endpoint, {
93+
method: 'POST',
94+
headers: { 'Authorization': `Bearer ${token}` },
95+
body: formData
96+
});
97+
return await response.json();
98+
},
7799
}
78100
];
79101

0 commit comments

Comments
 (0)