I am getting error Error: No value provided for input HTTP label: Bucket while putting an object ( a file ) in S3 using AWS-SDK V3 apis in a nodejs service. Here is code I am using :
const BUCKET_NAME = BILLING_BUCKET_ROOT;
const BUCKET_STORAGE_PATH = <FILE_PATH>+fileName;
// Setting up S3 upload parameters
const params = {
Bucket: BUCKET_NAME,
Key: BUCKET_STORAGE_PATH, // File name you want to save as in S3
Body: file
};
const s3Client = new S3Client({
region : process.env.REGION,
// forcePathStyle: true,
// endpoint: 'http://localhost:4566'
});
try {
(async () =>{
await s3Client.send(
new PutObjectCommand({
params
}),
);
})();
console.log(`${file.Key} uploaded successfully.`);
} catch (e) {
console.log(e);
}
I verified that name of bucket, region and all other params are there by putting console.log statement just before the new S3Client line. But still it complains with the error.
I also tried this on localstack. The commented lines in S3Client object creation are used while running on localstack. But on localstack, too, I get same error. I made sure the bucket exists in both the cases ( while executing this on localstack and also in AWS environment ). Not sure what is wrong.
By the way this function is executed in Lambda.
Any help is really appreciated.
Verified all the data exists before the problem line and also the necessary S3 bucket, and file exists before execution.