presignUrl()
将私有的 S3 对象通过使用你的 AWS 凭证签名,转换为公共 URL。
🌐 Takes a private S3 object and turns it into a public URL by signing with your AWS credentials.
示例
🌐 Example
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最好从 @remotion/lambda/client(从 v3.3.42 起可用)导入此函数,以避免 在无服务器函数中 出现问题。
参数
🌐 Arguments
一个具有以下属性的对象:
🌐 An object with the following properties:
region
存储桶所在的 AWS 区域。
🌐 The AWS region in which the bucket resides.
bucketName
资源存在的存储桶。该存储桶必须由 Remotion Lambda 创建。
🌐 The bucket where the asset exists. The bucket must have been created by Remotion Lambda.
objectKey
唯一标识存储在桶中的对象的键。
🌐 They key that uniquely identifies the object stored in the bucket.
expiresInSeconds
预签名 URL 过期前的秒数。必须是整数,并且为 >=1 和 <=604800(AWS 强制的最大值为 7 天)
🌐 The number of seconds before the presigned URL expires.
Must be an integer and >=1 and <=604800 (maximum of 7 days as enforced by AWS)
checkIfObjectExists
函数在生成预签名 URL 之前是否应该检查对象是否存在于存储桶中。默认值为 false。
🌐 Whether the function should check if the object exists in the bucket before generating the presigned url. Default false.
如果对象不存在且 checkIfObjectExists 是:
🌐 If the object does not exist and checkIfObjectExists is:
true,然后返回nullfalse,然后抛出一个异常
另请参阅
🌐 See also