【发布时间】:2021-07-18 19:43:30
【问题描述】:
所以,我正在尝试从我的数据库中的 URL 获取和下载流数据。从那里我试图将下载的内容放在一个 s3 存储桶中,但是,在 5 个 URL 中,只有前三个获取过程。这是我的循环代码
const uploadToS3 = async (uploadData) =>{
for (const file of uploadData){
const {data, headers} = await axios.get(file.attachment_url, {responseType: 'stream'});
try {
console.log(file.attachment_url)
const objectParams = {
Bucket: BUCKET_NAME,
Key: 'Resume'+'_'+file.candidate_id+' _ '+file.candidate_first_name,
ContentLength: headers['content-length'],
Body: data
};
await s3.putObject(objectParams).promise();
}catch (e){
console.log(e)
}
}
console.log('Finished')
}
有人遇到过这种情况吗?它也会抛出这个我也无法弄清楚的错误。
errorRequestTimeout: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
我已经检查过了,所有三个 URL 都被传递给了这个函数。它只处理 5 个中的 3 个。
【问题讨论】:
-
尝试使用upload代替putObject。
-
你的标题暗示这是关于 s3 但你确定不是 GET 请求失败了吗?
-
@404 不,我仔细检查了我是否从每个 URL 获取数据,确实是。
-
@404 原来是 S3 的重复密钥问题。它正在覆盖重复的名称键。
-
@Mu-Majid 原来是 S3 的重复密钥问题。它正在覆盖重复的名称键。
标签: javascript node.js amazon-web-services amazon-s3