本文整理汇总了TypeScript中aws-sdk.S3.getSignedUrl方法的典型用法代码示例。如果您正苦于以下问题:TypeScript S3.getSignedUrl方法的具体用法?TypeScript S3.getSignedUrl怎么用?TypeScript S3.getSignedUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aws-sdk.S3
的用法示例。
在下文中一共展示了S3.getSignedUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getPublicUrl
/**
* Fetch a public url for the resource.
*/
private getPublicUrl(key: string) {
return this.s3.getSignedUrl('getObject', {
Bucket: getConfig().BUCKET_NAME,
Key: key,
Expires: 24 * 60 * 30,
});
}
示例2: processGetAWS
export function processGetAWS(request: GetAWSSignRequest, callback: (GetAWSSignResponse) => void) {
aws.config.update({
accessKeyId: AWS_ACCESS_KEY,
secretAccessKey: AWS_SECRET_KEY,
signatureVersion: 'v4',
region: 'eu-central-1'
});
const s3 = new aws.S3();
let extension = path.extname(request.fileName == null ? 'default.jpg' : request.fileName);
const url = request.token + '/stage_' + request.stageId + '/quest_' + request.questId + '/f_' + new Date().getTime() + '_' + request.type + extension;
const s3_params = {
Bucket: S3_BUCKET,
Key: url,
Expires: 60,
ContentType: request.fileType,
ACL: 'public-read'
};
s3.getSignedUrl('putObject', s3_params, function (err, data) {
let result: GetAWSSignResponse;
if (err) {
result = {
success: false
};
}
else {
result = {
sign: data,
url: 'https://' + S3_BUCKET + '.s3.amazonaws.com/' + url,
success: true
};
}
callback(result);
});
}