我已使用以下代码将其上传到AWS,
var params = {
Bucket: config.awsBucket,
Key: file_name,
Body: data,
ServerSideEncryption : config.awsS3Encryption,
SSEKMSKeyId :config.awsKmsAccessKey
};
s3.putObject(params, function(err, data){
if (err) {
deferred.reject(err);
}else{
deferred.resolve(file_name);
}
})
但是当我使用下面的代码删除它时,导致错误“ Invalid key”。即使文件不存在,文件也会被删除,但文件已加密,如何解决?
params = {Bucket: config.awsBucket};
params.Delete = {Objects:[]};
data.Contents.forEach(function(content) {
params.Delete.Objects.push({Key: content.Key});
});
logger.info("params: ",params);
s3.deleteObjects(params, function(err, data) {
if (err){
logger.warn("Error deleting the file: ",err);
deferred.reject(err);
}
else{
callback();
}
});