file saving

This commit is contained in:
Ishaan Dey
2024-04-27 19:12:25 -04:00
parent d6769f3407
commit c4e1a894c3
6 changed files with 62 additions and 28 deletions

View File

@ -56,6 +56,18 @@ export default {
await env.R2.delete(fileId);
await env.R2.put(newFileId, data);
return success;
} else if (path === '/api/save' && method === 'POST') {
const renameSchema = z.object({
fileId: z.string(),
data: z.string(),
});
const body = await request.json();
const { fileId, data } = renameSchema.parse(body);
await env.R2.put(fileId, data);
return success;
} else if (path === '/api/init' && method === 'POST') {
const initSchema = z.object({