Skip to content

🎥 Make videos programmatically with React

convert to serve url generic

Jonny Burger346ff6f86d29
diff --git a/packages/lambda/src/functions/aws-implementation.ts b/packages/lambda/src/functions/aws-implementation.ts
index f556f8de8c..cc99e41f7a 100644
--- a/packages/lambda/src/functions/aws-implementation.ts
+++ b/packages/lambda/src/functions/aws-implementation.ts
@@ -8,6 +8,7 @@ import {lambdaLsImplementation} from '../io/list-objects';
import {lambdaReadFileImplementation} from '../io/read-file';
import {lambdaWriteFileImplementation} from '../io/write-file';
import type {AwsRegion} from '../regions';
+import {convertToServeUrlImplementation} from '../shared/convert-to-serve-url';
import {applyLifeCyleOperation} from '../shared/lifecycle-rules';
import {randomHashImplementation} from '../shared/random-hash';
import {getCurrentRegionInFunctionImplementation} from './helpers/get-current-region';
@@ -40,4 +41,5 @@ export const awsImplementation: ProviderSpecifics<AwsRegion> = {
readFile: lambdaReadFileImplementation,
writeFile: lambdaWriteFileImplementation,
headFile: lambdaHeadFileImplementation,
+ convertToServeUrl: convertToServeUrlImplementation,
};
diff --git a/packages/lambda/src/functions/compositions.ts b/packages/lambda/src/functions/compositions.ts
index 84889c9409..84725cc4bb 100644
--- a/packages/lambda/src/functions/compositions.ts
+++ b/packages/lambda/src/functions/compositions.ts
@@ -7,9 +7,7 @@ import {
internalGetOrCreateBucket,
} from '@remotion/serverless/client';
import {VERSION} from 'remotion/version';
-import type {AwsRegion} from '../regions';
import {decompressInputProps} from '../shared/compress-props';
-import {convertToServeUrl} from '../shared/convert-to-serve-url';
type Options = {
expectedBucketOwner: string;
@@ -64,9 +62,9 @@ export const compositionsHandler = async <Region extends string>(
providerSpecifics,
});
- const realServeUrl = convertToServeUrl({
+ const realServeUrl = providerSpecifics.convertToServeUrl({
urlOrId: lambdaParams.serveUrl,
- region: region as AwsRegion,
+ region,
bucketName,
});
diff --git a/packages/lambda/src/functions/start.ts b/packages/lambda/src/functions/start.ts
index 7565eeea0c..b8ab42c9b3 100644
--- a/packages/lambda/src/functions/start.ts
+++ b/packages/lambda/src/functions/start.ts
@@ -9,7 +9,6 @@ import {VERSION} from 'remotion/version';
import type {AwsRegion} from '../regions';
import {getLambdaClient} from '../shared/aws-clients';
import {overallProgressKey} from '../shared/constants';
-import {convertToServeUrl} from '../shared/convert-to-serve-url';
import {
generateRandomHashWithLifeCycleRule,
validateDeleteAfter,
@@ -53,9 +52,9 @@ export const startHandler = async <Region extends string>(
providerSpecifics,
})
).bucketName;
- const realServeUrl = convertToServeUrl({
+ const realServeUrl = providerSpecifics.convertToServeUrl({
urlOrId: params.serveUrl,
- region: region as AwsRegion,
+ region,
bucketName,
});
diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.ts
index 4c4c8be76c..7afb2d68e7 100644
--- a/packages/lambda/src/functions/still.ts
+++ b/packages/lambda/src/functions/still.ts
@@ -27,7 +27,6 @@ import {
artifactName,
overallProgressKey,
} from '../shared/constants';
-import {convertToServeUrl} from '../shared/convert-to-serve-url';
import {isFlakyError} from '../shared/is-flaky-error';
import {validateDownloadBehavior} from '../shared/validate-download-behavior';
import {validateOutname} from '../shared/validate-outname';
@@ -119,9 +118,9 @@ const innerStillHandler = async <Region extends string>({
providerSpecifics,
});
- const serveUrl = convertToServeUrl({
+ const serveUrl = providerSpecifics.convertToServeUrl({
urlOrId: lambdaParams.serveUrl,
- region: region as AwsRegion,
+ region,
bucketName,
});
diff --git a/packages/lambda/src/shared/convert-to-serve-url.ts b/packages/lambda/src/shared/convert-to-serve-url.ts
index 000ec758bd..fc82c2725e 100644
--- a/packages/lambda/src/shared/convert-to-serve-url.ts
+++ b/packages/lambda/src/shared/convert-to-serve-url.ts
@@ -1,7 +1,7 @@
import type {AwsRegion} from '../regions';
import {DOCS_URL} from './docs-url';
-export const convertToServeUrl = ({
+export const convertToServeUrlImplementation = ({
urlOrId,
region,
bucketName,
diff --git a/packages/lambda/src/test/mock-implementation.ts b/packages/lambda/src/test/mock-implementation.ts
index 2d247c9b11..e6e9811216 100644
--- a/packages/lambda/src/test/mock-implementation.ts
+++ b/packages/lambda/src/test/mock-implementation.ts
@@ -1,6 +1,7 @@
import type {ProviderSpecifics} from '@remotion/serverless';
import {Readable} from 'stream';
import type {AwsRegion} from '../regions';
+import {convertToServeUrlImplementation} from '../shared/convert-to-serve-url';
import {
addMockBucket,
getMockBuckets,
@@ -105,4 +106,5 @@ export const mockImplementation: ProviderSpecifics<AwsRegion> = {
LastModified: new Date(),
});
},
+ convertToServeUrl: convertToServeUrlImplementation,
};
diff --git a/packages/serverless/src/provider-implementation.ts b/packages/serverless/src/provider-implementation.ts
index 188a683f7f..34a93e1095 100644
--- a/packages/serverless/src/provider-implementation.ts
+++ b/packages/serverless/src/provider-implementation.ts
@@ -92,6 +92,12 @@ type HeadFile<Region extends string> = (
type RandomHash = () => string;
+type ConvertToServeUrl<Region extends string> = (params: {
+ urlOrId: string;
+ region: Region;
+ bucketName: string;
+}) => string;
+
export type ProviderSpecifics<Region extends string> = {
getChromiumPath: () => string | null;
getCurrentRegionInFunction: () => Region;
@@ -106,4 +112,5 @@ export type ProviderSpecifics<Region extends string> = {
readFile: ReadFile<Region>;
writeFile: WriteFile<Region>;
headFile: HeadFile<Region>;
+ convertToServeUrl: ConvertToServeUrl<Region>;
};