presignUrl()
Takes a private S3 object and turns it into a public URL by signing with your AWS credentials.
Example
tsimport {presignUrl } from'@remotion/lambda/client';consturl =await({ region, bucketName, objectKey, checkIfObjectExists, expiresInSeconds, forcePathStyle, requestHandler, }: PresignUrlInput ): Promiseimport presignUrl">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 existconsturl2 =awaitpresignUrl ({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 existnotePreferrably import this function from
@remotion/lambda/client(available from v3.3.42) to avoid problems inside serverless functions.Arguments
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
>=1and<=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
checkIfObjectExistsis:
true, thennullis returnedfalse, then an exception is thrown