节点 js aws-sdk 连接
node js aws-sdk connect
我有一个类似 aruba-get-rds-backups.getaws.arubanetworks.com/sp/
的 s3 存储桶,其中 aruba-get-rds-backups.getaws.arubanetworks.com
是存储桶名称,/sp 是一种子文件夹 如何使用 getObject 方法访问存储桶中 /sp 文件夹中的文件nodejs 中的 aws-sdk
async function getS3Obj(bucketName, bucketKey) {
let AWS = require("aws-sdk");
let s3 = new AWS.S3({ apiVersion: "2006-03-01" }); // provide credentials, if needed
const params = {
Bucket: bucketName,
Key: bucketKey,
};
let content = await s3.getObject(params).promise();
// assuming here you're downloading ascii file
return content.Body!==undefined ? content.Body.toString() : null;
}
( async () =>{
try {
// your call will likely to be something...
const content = await getS3Obj("bucketName", "sp/file.txt");
console.log(content);
} catch (error) {
console.log(error);
}
})();
我有一个类似 aruba-get-rds-backups.getaws.arubanetworks.com/sp/
的 s3 存储桶,其中 aruba-get-rds-backups.getaws.arubanetworks.com
是存储桶名称,/sp 是一种子文件夹 如何使用 getObject 方法访问存储桶中 /sp 文件夹中的文件nodejs 中的 aws-sdk
async function getS3Obj(bucketName, bucketKey) {
let AWS = require("aws-sdk");
let s3 = new AWS.S3({ apiVersion: "2006-03-01" }); // provide credentials, if needed
const params = {
Bucket: bucketName,
Key: bucketKey,
};
let content = await s3.getObject(params).promise();
// assuming here you're downloading ascii file
return content.Body!==undefined ? content.Body.toString() : null;
}
( async () =>{
try {
// your call will likely to be something...
const content = await getS3Obj("bucketName", "sp/file.txt");
console.log(content);
} catch (error) {
console.log(error);
}
})();