MCPcopy Index your code
hub / github.com/CapSoftware/Cap / parseVideoIdOrFileKey

Function parseVideoIdOrFileKey

apps/web/app/api/upload/utils.ts:1–24  ·  view source on GitHub ↗
(
	userId: string,
	input:
		| { videoId: string; subpath: string }
		| {
				// deprecated
				fileKey: string;
		  },
)

Source from the content-addressed store, hash-verified

1export function parseVideoIdOrFileKey(
2 userId: string,
3 input:
4 | { videoId: string; subpath: string }
5 | {
6 // deprecated
7 fileKey: string;
8 },
9) {
10 let videoId: string;
11 let subpath: string;
12
13 if ("fileKey" in input) {
14 const [_, _videoId, ...subpathParts] = input.fileKey.split("/");
15 if (!_videoId) throw new Error("Invalid fileKey");
16 videoId = _videoId;
17 subpath = subpathParts.join("/");
18 } else {
19 videoId = input.videoId;
20 subpath = input.subpath;
21 }
22
23 return `${userId}/${videoId}/${subpath}`;
24}

Callers 2

signed.tsFile · 0.90
getMultipartFileKeyFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected