【发布时间】:2023-03-26 07:45:01
【问题描述】:
我正在学习 Nodejs。我面临一个小问题。我正在将文件上传到谷歌云服务。所有类型的文件都在上传,我正在获得文件的签名 URL。我正在将签名的 URL 从一个 nodejs 服务器发送到另一台 nodejs 服务器。在上传 jpg 或 png 文件时,它的成功并将响应返回到另一台服务器。 但问题是,当我上传 xlsx(excel 文件)时,我没有得到对另一台服务器的响应。仅在我仅上传 excel 文件时才发生。
有什么解决办法吗?
文件上传到 GCS 的第一个 Nodejs 服务器->
if(is_valid_request){
interface.gcpFileUpload(req, (data)=>{
console.log("response = "+ JSON.stringify(data));
res.json(data)
})
} else{
res.json({success:0,err:"request is not valid"});
}
另一个我想得到响应的服务器->
getResponse(source, filename, destination, bucket_name, json_url, callback) {
var formData = {
file: fs.createReadStream(source),
filename: filename,
json_url: json_url,
destination: destination,
bucket_name: bname
}
var options = {
'method': 'POST',
'url': endpoint_of_another_server,
'headers': {
'api_key': key,
'Content-Type': 'application/json',
},
formData: formData,
}
console.log("I AM RUNNING TILL HERE")
request(options, function (error, response) {
console.log("WE ARE GETTING SOME RESPONSE " + response);
return callback(response.body);
})
}
【问题讨论】:
-
任何错误或调试信息?我们可以看看你的实现代码吗?
-
我更新了问题请看。
标签: node.js api google-cloud-platform request form-data