server/api/storage.post.ts
Storage
Example
Save a persistent file and return its public URL.
export const config = {
filter: {
name: z.string().regex(/^[a-z0-9-]{1,40}$/),
content: z.string().min(1).max(10_000),
},
sample: {
name: "welcome",
content: "Hello from Cake20 Storage!",
},
};
export default async (data: Input<typeof config.filter>) => {
const path = `notes/${data.name}.txt`;
await storage.put(path, data.content);
return { path, url: storage.url(path) };
};