Closed ganna-shmatova closed 7 years ago
After a lot of research I found an alternative that works:
request.post('/upload').expect(200)
.field('uploadTo', './test/dir/nonbinary.txt')
.attach('file', fs.createReadStream('./test/nonbinary.txt'))
.end(assert('upload'));
turns out you need to attach a read stream to be able to upload the correct headers were automatically sent after this
(the call must also have been post
, and i had to use fields
method to send in extra data -- send(obj) was not being caught anymore by express)
Mixing of .send()
and .attach()
doesn't work. The current version warns about it.
happens with both:
and
application/x-www-formurlencoded
.Am I missing something...? =S