![](/img/trans.png)
[英]Post request with multipart/form-data in appengine python not working
[英]Nodejs Post request is not working in Postman?
我做了一篇谷歌雲視覺的帖子 API 用於檢測圖像文本,現在我正在嘗試在 postman 中測試這篇帖子 API ,但它不起作用。 沒有得到任何回應
app.post("/images", upload.single("file"), function (req, res) {
client.textDetection(req.file.path)
.then((results) => {
res.send(results);
})
.catch((err) => {
res.status(400).send(err);
});
});
在postman -
使用 url - http://localhost:8088/images
var http = require('http');
var formidable = require('formidable');
var fs = require('fs');
http.createServer(function (req, res) {
if (req.url == '/fileupload') {
var form = new formidable.IncomingForm();
form.parse(req, function (err, fields, files) {
var oldpath = files.filetoupload.filepath;
var newpath = 'C:/Users/Your Name/' +
files.filetoupload.originalFilename;
fs.rename(oldpath, newpath, function (err) {
if (err) throw err;
res.write('File uploaded and moved!');
res.end();
});
});
} else {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<form action="fileupload" method="post" enctype="multipart/form-
data">');
res.write('<input type="file" name="filetoupload"><br>');
res.write('<input type="submit">');
res.write('</form>');
return res.end();
}
}).listen(8080);
upload.single("file")
表示multer
將查找名為file
的表單部分。
但是,在您的 Postman 屏幕截圖中,名稱(“KEY”)為空。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.