我的 key 中有空格(测试 12/3/2017.csv),但如果没有空格,则 key 可以正常工作。我正在使用 aws javascript sdk。
var params = {
Bucket: bucketname,
CopySource: `/bucketname/test 12/3/2017.csv`,
Key: `test 12/3/2017.csv`
};
s3bucket.copyObject(params, function(err, data) {
if (err){
console.log(err, err.stack);
debugger
} else {
console.log(data);
debugger
}
});
最佳答案
问题在于 key 需要进行 URL 编码。
如 this 所示问题,如果您的 key 中确实有空格,有多种选择可以解决该问题。
在这个问题中适用于OP的一个选项是使用encodeURIComponent(file.name)
。
关于javascript - 无法将文件复制到另一个存储桶,显示错误(NoSuchKey : The specified key does not exist.),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50832228/