Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(api): expose upload targets in batch signed URLs

Richie McIlroyff3dc16b5727
diff --git a/apps/web/app/api/upload/[...route]/signed.ts b/apps/web/app/api/upload/[...route]/signed.ts
index 31d58562b..63224b0f7 100644
--- a/apps/web/app/api/upload/[...route]/signed.ts
+++ b/apps/web/app/api/upload/[...route]/signed.ts
@@ -64,7 +64,7 @@ app.post(
if (video.ownerId !== user.id) return c.json({ error: "Forbidden" }, 403);
const videoDomain = decodeVideo(video);
- const urls = await Effect.gen(function* () {
+ const batch = await Effect.gen(function* () {
const [bucket] = yield* Storage.getAccessForVideo(videoDomain);
const entries = yield* Effect.all(
@@ -75,17 +75,19 @@ app.post(
contentType: contentTypeForSubpath(subpath),
method: "put",
})
- .pipe(Effect.map((url) => [subpath, url] as const));
+ .pipe(Effect.map((upload) => [subpath, upload] as const));
}),
{ concurrency: "unbounded" },
);
- return Object.fromEntries(
+ const uploads = Object.fromEntries(entries);
+ const urls = Object.fromEntries(
entries.map(([subpath, upload]) => [subpath, upload.url]),
);
+ return { uploads, urls };
}).pipe(runPromise);
- return c.json({ urls });
+ return c.json(batch);
} catch (error) {
console.error("Batch signed URL generation failed:", error);
return c.json({ error: "Internal server error" }, 500);