Public
Script
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { S3Client } from "https://deno.land/x/s3_lite_client@0.6.1/mod.ts";
const cloudflareR2client = new S3Client({
endPoint: Deno.env.get("cloudflareR2Endpoint"), // This stores as secrets in val.town
region: "auto",
bucket: Deno.env.get("cloudflareR2Bucket"), // This stores as secrets in val.town
accessKey: Deno.env.get("cloudflareR2Key"), // This stores as secrets in val.town
secretKey: Deno.env.get("cloudflareR2Secret"), // This stores as secrets in val.town
});
export default async function(req: Request): Promise<Response> {
let currentDate = new Date().toISOString(); // Otherwise, we take the current date
await cloudflareR2client.putObject("transcription-" + currentDate + ".json", req.body);
return Response.json({ ok: true });
}
August 16, 2024