我正在尝试将文件发送到 s3,
@aws-sdk/client-s3
我认为我一切都正确,但发送时我不断收到错误No value provided for input HTTP label: Key
这是我的console.log
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.
它已经拿到钥匙了
bfbfr.jpg
,怎么还抱怨钥匙没拿?
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));
在使用“Bucket”属性的环境变量时,我遇到了类似的问题。 我收到了相同的错误消息,如问题中所述。 事实证明我在环境变量名称中有一个拼写错误。
const params = {
Bucket: process.env.BUCKET_NAME,
Key: "test.txt",
Body: "some content",
};
对我来说,它抛出了错误,因为我用小K写了密钥,而应该用大写K
写