🎥 Make videos programmatically with React
`@remotion/lambda`: Fix exports > 2GB
Jonny Burger9a3ef990eb12
diff --git a/packages/lambda-client/package.json b/packages/lambda-client/package.jsonindex a704c2e4fc..669698d694 100644--- a/packages/lambda-client/package.json+++ b/packages/lambda-client/package.json@@ -22,6 +22,7 @@"@aws-sdk/client-s3": "3.738.0","@aws-sdk/client-service-quotas": "3.738.0","@aws-sdk/client-sts": "3.738.0",+ "@aws-sdk/lib-storage": "3.738.0","mime-types": "2.1.34"},"devDependencies": {diff --git a/packages/lambda-client/src/write-file.ts b/packages/lambda-client/src/write-file.tsindex c53db6c263..ef55d311b8 100644--- a/packages/lambda-client/src/write-file.ts+++ b/packages/lambda-client/src/write-file.ts@@ -1,5 +1,7 @@/* eslint-disable no-console */+import type {ObjectCannedACL, PutObjectCommandInput} from '@aws-sdk/client-s3';import {PutObjectCommand} from '@aws-sdk/client-s3';+import {Upload} from '@aws-sdk/lib-storage';import type {CustomCredentials,WriteFileInput,@@ -9,6 +11,9 @@ import type {AwsProvider} from './aws-provider';import {getContentDispositionHeader} from './content-disposition-header';import {getS3Client} from './get-s3-client';+// Files larger than 100MB will use multipart upload+const MULTIPART_THRESHOLD = 100 * 1024 * 1024; // 5MB in bytes+const tryLambdaWriteFile = async ({bucketName,key,@@ -20,28 +25,53 @@ const tryLambdaWriteFile = async ({customCredentials,forcePathStyle,}: WriteFileInput<AwsProvider>): Promise<void> => {- await getS3Client({+ const client = getS3Client({region,customCredentials: customCredentials as CustomCredentials<AwsProvider>,forcePathStyle,- }).send(- new PutObjectCommand({- Bucket: bucketName,- Key: key,- Body: body,- ACL:- privacy === 'no-acl'- ? undefined- : privacy === 'private'- ? 'private'- : 'public-read',- ExpectedBucketOwner: customCredentials+ });++ const params: PutObjectCommandInput = {+ Bucket: bucketName,+ Key: key,+ Body: body,+ ACL:+ privacy === 'no-acl'? undefined- : (expectedBucketOwner ?? undefined),- ContentType: mimeTypes.lookup(key) || 'application/octet-stream',- ContentDisposition: getContentDispositionHeader(downloadBehavior),- }),- );+ : ((privacy === 'private'+ ? 'private'+ : 'public-read') as ObjectCannedACL),+ ExpectedBucketOwner: customCredentials+ ? undefined+ : (expectedBucketOwner ?? undefined),+ ContentType: mimeTypes.lookup(key) || 'application/octet-stream',+ ContentDisposition: getContentDispositionHeader(downloadBehavior),+ };++ // Determine file size+ const size =+ body instanceof Buffer || body instanceof Uint8Array+ ? body.length+ : body instanceof Blob+ ? body.size+ : typeof body === 'string'+ ? Buffer.from(body).length+ : null;++ // Use multipart upload for large files or streams (where we can't determine size)+ if (size === null || size > MULTIPART_THRESHOLD) {+ const upload = new Upload({+ client,+ params,+ queueSize: 4, // number of concurrent uploads+ partSize: 5 * 1024 * 1024, // chunk size of 5MB+ });++ await upload.done();+ } else {+ // Use regular PutObject for small files+ await client.send(new PutObjectCommand(params));+ }};export const lambdaWriteFileImplementation = async (diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 6053d4103a..fb85c367c8 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1477,6 +1477,9 @@ importers:'@aws-sdk/client-sts':specifier: 3.738.0version: 3.738.0+ '@aws-sdk/lib-storage':+ specifier: 3.738.0+ version: 3.738.0(@aws-sdk/[email protected])'@aws-sdk/s3-request-presigner':specifier: 3.738.0version: 3.738.0@@ -4261,8 +4264,8 @@ packages:dependencies:'@aws-sdk/client-s3': 3.738.0'@smithy/abort-controller': 4.0.1- '@smithy/middleware-endpoint': 4.0.2- '@smithy/smithy-client': 4.1.2+ '@smithy/middleware-endpoint': 4.0.6+ '@smithy/smithy-client': 4.1.6buffer: 5.6.0events: 3.3.0stream-browserify: 3.0.0@@ -13875,7 +13878,7 @@ packages:resolution: {integrity: sha512-Z9m67CXizGpj8CF/AW/7uHqYNh1VXXOn9Ap54fenWsCa0HnT4cJuE61zqG3cBkTZJDCy0wHJphilI41co/PE5g==}engines: {node: '>=18.0.0'}dependencies:- '@smithy/core': 3.1.1+ '@smithy/core': 3.1.5'@smithy/middleware-serde': 4.0.1'@smithy/node-config-provider': 4.0.1'@smithy/shared-ini-file-loader': 4.0.1@@ -14038,12 +14041,12 @@ packages:resolution: {integrity: sha512-0yApeHWBqocelHGK22UivZyShNxFbDNrgREBllGh5Ws0D0rg/yId/CJfeoKKpjbfY2ju8j6WgDUGZHYQmINZ5w==}engines: {node: '>=18.0.0'}dependencies:- '@smithy/core': 3.1.1- '@smithy/middleware-endpoint': 4.0.2+ '@smithy/core': 3.1.5+ '@smithy/middleware-endpoint': 4.0.6'@smithy/middleware-stack': 4.0.1'@smithy/protocol-http': 5.0.1'@smithy/types': 4.1.0- '@smithy/util-stream': 4.0.2+ '@smithy/util-stream': 4.1.2tslib: 2.8.1dev: false