MCPcopy Index your code
hub / github.com/heygen-com/hyperframes / downloadS3ObjectToFile

Function downloadS3ObjectToFile

packages/aws-lambda/src/s3Transport.ts:63–76  ·  view source on GitHub ↗
(
  client: S3Client,
  uri: string,
  destPath: string,
)

Source from the content-addressed store, hash-verified

61
62/** Stream an S3 object to a local file path. Throws if the body is missing. */
63export async function downloadS3ObjectToFile(
64 client: S3Client,
65 uri: string,
66 destPath: string,
67): Promise<void> {
68 const { bucket, key } = parseS3Uri(uri);
69 const response = await client.send(new GetObjectCommand({ Bucket: bucket, Key: key }));
70 const body = response.Body as NodeJS.ReadableStream | undefined;
71 if (!body) {
72 throw new Error(`[s3Transport] s3 GetObject returned empty body for ${uri}`);
73 }
74 mkdirSync(dirname(destPath), { recursive: true });
75 await pipeline(body, createWriteStream(destPath));
76}
77
78/**
79 * Upload a local file's contents to an S3 URI using a streaming

Callers 5

runLambdaLocalRenderFunction · 0.90
handlePlanFunction · 0.85
handleRenderChunkFunction · 0.85
handleAssembleFunction · 0.85
downloadChunkObjectsFunction · 0.85

Calls 2

parseS3UriFunction · 0.85
sendMethod · 0.45

Tested by

no test coverage detected