Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用预签名url将流式上载到S3失败,错误为403_Node.js_Amazon S3_Request - Fatal编程技术网

Node.js 使用预签名url将流式上载到S3失败,错误为403

Node.js 使用预签名url将流式上载到S3失败,错误为403,node.js,amazon-s3,request,Node.js,Amazon S3,Request,使用nodeJs将二进制文件上载到预先签名的s3url,当主体作为缓冲区呈现时,请求成功,但当作为流呈现时,403失败。文档表明body可以是缓冲区或流 // this succeeds request({ url: uploadUrl, headers: { 'Content-Length':length } method: 'put', body: fs.readFileSync(name), },(err,resp,body)=>{ .. }) // t

使用nodeJs将二进制文件上载到预先签名的s3url,当主体作为缓冲区呈现时,请求成功,但当作为流呈现时,403失败。文档表明body可以是缓冲区或流

// this succeeds
request({
  url: uploadUrl,
  headers: {
    'Content-Length':length
  }
  method: 'put',
  body: fs.readFileSync(name),
},(err,resp,body)=>{
..
})

// this fails with 403
request({
  url: uploadUrl,
  method: 'put',
  headers: {
    'Content-Length':length
  }
  body: fs.createReadStream(name),
},(err,resp,body)=>{
..
})