本文整理匯總了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);
});
}