MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / parseS3Uri

Function parseS3Uri

packages/aws-lambda/src/s3Transport.ts:40–55  ·  view source on GitHub ↗
(uri: string)

Source from the content-addressed store, hash-verified

38
39/** Parse `s3://bucket/key/path` → `{ bucket, key }`. Throws on malformed input. */
40export function parseS3Uri(uri: string): S3Location {
41 if (!uri.startsWith("s3://")) {
42 throw new Error(`[s3Transport] expected s3:// URI, got: ${JSON.stringify(uri)}`);
43 }
44 const rest = uri.slice("s3://".length);
45 const slash = rest.indexOf("/");
46 if (slash === -1) {
47 throw new Error(`[s3Transport] missing key in s3 URI: ${JSON.stringify(uri)}`);
48 }
49 const bucket = rest.slice(0, slash);
50 const key = rest.slice(slash + 1);
51 if (!bucket || !key) {
52 throw new Error(`[s3Transport] empty bucket or key in s3 URI: ${JSON.stringify(uri)}`);
53 }
54 return { bucket, key };
55}
56
57/** Build `s3://bucket/key` from a location. */
58export function formatS3Uri(loc: S3Location): string {

Callers 5

downloadChunkObjectsFunction · 0.85
validateEventS3UrisFunction · 0.85
downloadS3ObjectToFileFunction · 0.85
uploadFileToS3Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected