chore: add write request to kdmod

This commit is contained in:
KernelDeimos 2024-06-27 18:24:57 -04:00 committed by Eric Dubé
parent e9ee3191e9
commit 2faaeaedb3

View File

@ -74,6 +74,28 @@ const request_examples = [
const resp = await this.fetch(...a);
return await this.out(resp);
},
},
{
name: 'write file',
fetch: async (path, str) => {
const endpoint = `${window.api_origin}/write`;
const token = puter.authToken;
const blob = new Blob([str], { type: 'text/plain' });
const formData = new FormData();
formData.append('create_missing_ancestors', true);
formData.append('path', path);
formData.append('size', 8);
formData.append('overwrite', true);
formData.append('file', blob, 'something.txt');
const response = await fetch(endpoint, {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}` },
body: formData
});
return await response.json();
},
}
];