为什么这与流式阅读器形成附件;我真的不管用
Why this forms attachment with stream reader doesn't work truly?
我想读取一个图像并将其附加到请求主体,如下所示:
// Sending files to server by adding and posting theme
// 1. loop through an array of file path pair ['file', 'path' ]
// 2. pass result to request function an post it
一些代码如下:
forms = [];
len = 3;
while (len > 0){
forms.push({ 'fileName': fs.createReadStream (path) })
len--
}
async.each(forms, function(form) {
request.post( { url : url, formData: form }, function(err, response) {
console.log(response.body)
});
});
只有一个请求和一个表单元素。
您应该能够使用Array.prototype.forEach()
forms.forEach(form =>
request.post( { url : url, formData: form }
, (err, response) => console.log(response.body))
);
相关文章:
- 指令加载真的很长,检查加载时间的方法
- JS,“;对象”;,这个和那个.来自蟒蛇这真的让我很困惑.(双关语)
- 为什么这是真的:parseInt(1111111111111,2)===parseInt(111111111111,2)
- (false==false==true)怎么可能是真的
- 使用js/jQuery检查对象(而不是元素)是否真的存在
- 为什么typeof的数组的数组的未定义值返回为“0”;未定义的“;我的条件不认为是真的
- coffescript/javascript函数数组的行为真的很奇怪
- Passport.js`isAuthenticated()`不一致的行为;当它应该是真的时候是假的
- 真的没有办法在Firefox中自动杀死没有响应的脚本吗
- html() 真的取代了 html 代码吗?
- 有没有办法检测用户是否真的远离计算机
- 饶恕是真的就是假的
- Extjs form.reset() 不作为 trackResetOnLoad 工作是真的
- 在 JavaScript 中真的需要提升以实现相互递归吗?
- 为什么 1.2 == true 返回 false 如果布尔值 (1.2) 实际上是真的
- IE11真的与getNamedItem()JS函数不兼容吗
- blink()方法真的被弃用了吗
- 我真的必须重新加载我的页面两次吗
- 凌驾于违约之上真的有危险吗;控制台'在节点中
- xmlHttp.status==200从来都不是真的