using "@aws-sdk/client-s3": "^3.481.0", and keep getting the error at send line
let S3_Config = {
region: process.env.S3_REGION,
credentials: {
accessKeyId: process.env.S3_ACCESS_KEY_ID,
secretAccessKey: process.env.S3_ACCESS_SECRET_KEY,
},
};
const s3_client = new S3Client(S3_Config);
const s3_params = {
Bucket: process.env.S3_BUCKET_NAME , // required
MaxKeys: 20,
};
const _command = new ListBucketsCommand(s3_params);
const response = await s3_client.send(_command);
Argument of type ‘ListBucketsCommand’ is not assignable to parameter
of type ‘Command<ServiceInputTypes, ServiceInputTypes,
ServiceOutputTypes, ServiceOutputTypes,
SmithyResolvedConfiguration>’. Type
‘ListBucketsCommand’ is missing the following properties from type
‘Command<ServiceInputTypes, ServiceInputTypes, ServiceOutputTypes,
ServiceOutputTypes, SmithyResolvedConfiguration>’:
input, middlewareStack, resolveMiddlewarets(2345)
This is the exact example as shown https://www.npmjs.com/package/@aws-sdk/client-s3?activeTab=readme
2
Answers
ListBucketsCommand in AWS SDK v3 doesn’t require any input parameters, so pass an empty object {} when creating the command.
Your code looks fine . Not sure why it is throwing error .
But below there’s one alternate solution —
Hope it helps .