加入引用
"aws-sdk": "^2.1604.0"
具体代码使用示例
var AWS = require('aws-sdk/clients/s3');
var client = new S3({
accessKeyId: '',
secretAccessKey: '',
endpoint: '',
s3ForcePathStyle: true,
});
let bucketName = req.query.bucket_name;
let fileKey = req.query.file_key;
const expires = 24 * 60 * 60
let internalUrl = await client.getSignedUrl('getObject', {
Bucket: bucketName,
Key: fileKey,
Expires: expires
});