Pass picture file parameter to specific interface location under Node.js
来源:互联网 发布:淘宝闺蜜投诉平台 编辑:程序博客网 时间:2024/06/05 09:40
I have tried many other methods, but all ended in failure. The below is the only one that worked successfully.
var r = request.post('http://apicn.faceplusplus.com/detection/detect', function(err, httpResponse, body) {if (err) {return console.error('Failed:', err);};console.log('Server responded with:', body);})var form = r.form();form.append('api_key', apiKey);form.append('api_secret', apiSecret);form.append('img', fs.createReadStream('./static/generateCaptcha.png'));form.append('attribute', 'glass,pose,gender,age,race,smiling');
To let the above-mentioned code snippet work, you should firstly require two node.js modules:
var fs = require('fs');var request = require('request');
And then, you need to get your API key and API secret from the official website of the API.
------------------------------------------Updated on Feb. 3, 2016--------------------------------------------
The following code also works normally:
request.post({url: 'http://apicn.faceplusplus.com/detection/detect',formData: {'api_key': apiKey,'api_secret': apiSecret,'img': fs.createReadStream('./static/generateCaptcha.png'),'attribute': 'glass,pose,gender,age,race,smiling'}}, function(err, httpResponse, body) {console.log(body);});
0 0
- Pass picture file parameter to specific interface location under Node.js
- How to roll back/cherry-pick a specific file to a node you want?
- Upload file to specific folder
- How to pass the paramater of Node.js or io.js into native C/C++ function.
- How to pass the paramater of Node.js or io.js into native C/C++ function.
- How to Pass IList As parameter to wcf service
- How to download a file with Node.js?
- How to download a file with Node.js?
- Interface Parameter
- How to merge/cover specific file using git
- MVC - Pass array from model to JS
- warning MIDL2039 : interface does not conform to [oleautomation] attribute : [ Parameter ... ...
- Output error file to the following location
- How to Insert Word Image at Specific Location with C#, VB.NET
- Intro to Node.js
- Pass CSV string as parameter to your SQL Server stored procedure
- node-inspector,is a debugger interface for Node.js applications
- Distributing to Specific Screens
- myeclipse中java文件头注释格式设置
- C和C++库中的排序函数——sort与qsort解析
- ORA-02019:未找到远程数据库的连接说明(数据库链接创建)
- Windows编程之COM组件
- 黑马程序员-----------快速了解java基础小知识
- Pass picture file parameter to specific interface location under Node.js
- Build模式——自由扩展
- alibaba dexposed使用须知
- swift里的函数和闭包
- 千变万化的ViewPager切换动画(一、简单的设置动画)
- Light OJ 1027 A Dangerous Maze (概率题)
- java基础
- VHDL语法简单总结
- uva1335 - Beijing Guards