packages/docs/docs/lambda/presignurl.mdx
Takes a private S3 object and turns it into a public URL by signing with your AWS credentials.
import {presignUrl} from '@remotion/lambda/client';
const url = await presignUrl({
region: 'us-east-1',
bucketName: 'remotionlambda-c7fsl3d',
objectKey: 'assets/sample.png',
expiresInSeconds: 900,
checkIfObjectExists: true,
});
console.log(url); // `string` - or `null` if object doesn't exist
const url2 = await presignUrl({
region: 'us-east-1',
bucketName: 'remotionlambda-c7fsl3d',
objectKey: 'assets/sample.png',
expiresInSeconds: 900,
checkIfObjectExists: false,
});
console.log(url); // always a string, or exception if object doesn't exist
:::note
Preferrably import this function from @remotion/lambda/client (available from v3.3.42) to avoid problems inside serverless functions.
:::
An object with the following properties:
regionThe AWS region in which the bucket resides.
bucketNameThe bucket where the asset exists. The bucket must have been created by Remotion Lambda.
objectKeyThey key that uniquely identifies the object stored in the bucket.
expiresInSecondsThe number of seconds before the presigned URL expires.
Must be an integer and >=1 and <=604800 (maximum of 7 days as enforced by AWS)
checkIfObjectExistsWhether the function should check if the object exists in the bucket before generating the presigned url. Default false.
If the object does not exist and checkIfObjectExists is:
true, then null is returnedfalse, then an exception is thrown