amazon-s3

No value provided for input HTTP label: Key


I'm trying to send a file to s3, @aws-sdk/client-s3 I think i got everything correct but when sending I keep getting the error No value provided for input HTTP label: Key

here is my console.log of the buckeparam

// result of console.log
the bucket {
  Bucket: 'image-camlist',
  Body: Blob { size: 187759, type: 'image/jpeg' },
  key: 'bfbfr.jpg'
}
Error Error: No value provided for input HTTP label: Key.

it got the key bfbfr.jpg already, how come it's still complaining about the key ?


Solution

  • const { S3Client, PutObjectCommand } = require(‘@aws-sdk/client-s3’);
    const params = {
        Bucket: "image-camlist",
        Key: 'bfbfr.txt', // Pay attention to the casing of Key property
        Body: 'hello world',
    };
    
    client.send(new PutObjectCommand(params));