Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web): gate uploads on Drive support vs S3 writable access

Richie McIlroyc522e404ed69
diff --git a/apps/web/app/api/desktop/[...route]/video.ts b/apps/web/app/api/desktop/[...route]/video.ts
index b5dc93773..72b6d9b2e 100644
--- a/apps/web/app/api/desktop/[...route]/video.ts
+++ b/apps/web/app/api/desktop/[...route]/video.ts
@@ -22,7 +22,12 @@ import { z } from "zod";
import { invalidateGoogleDriveStorageQuotaCache } from "@/lib/google-drive-storage-quota";
import { runPromise } from "@/lib/server";
import { decodeStorageVideo } from "@/lib/video-storage";
-import { isFromDesktopSemver, UPLOAD_PROGRESS_VERSION } from "@/utils/desktop";
+import {
+ GOOGLE_DRIVE_UPLOAD_FEATURE,
+ hasDesktopFeature,
+ isFromDesktopSemver,
+ UPLOAD_PROGRESS_VERSION,
+} from "@/utils/desktop";
import { stringOrNumberOptional } from "@/utils/zod";
import { withAuth } from "../../utils";
@@ -165,9 +170,14 @@ app.get(
const videoName =
name ??
`Cap ${isScreenshot ? "Screenshot" : "Recording"} - ${formattedDate}`;
- const writable = await Storage.getWritableAccessForUser(user.id).pipe(
- runPromise,
+ const clientSupportsGoogleDriveUpload = hasDesktopFeature(
+ c.req,
+ GOOGLE_DRIVE_UPLOAD_FEATURE,
);
+ const writable = await (clientSupportsGoogleDriveUpload
+ ? Storage.getWritableAccessForUser(user.id)
+ : Storage.getS3WritableAccessForUser(user.id)
+ ).pipe(runPromise);
await db()
.insert(videos)