node.js - POSTing RAW body with restify client -


i'm trying post raw body restify. have receive side correct, when using postman can send raw zip file, , file correctly created on server's file system. however, i'm struggling write test in mocha. here code have, appreciated.

i've tried approach.

const should = require('should'); const restify = require('restify'); const fs = require('fs');  const port = 8080; const url = 'http://localhost:' + port;  const client = restify.createjsonclient({     url: url,     version: '~1.0' });    const testpath = 'test/assets/test.zip'; fs.existssync(testpath).should.equal(true);   const readstream = fs.createreadstream(testpath);  client.post('/v1/deploy', readstream, function(err, req, res, data) {         if (err) {             throw new error(err);         }          should(res).not.null();         should(res.statuscode).not.null();         should(res.statuscode).not.undefined();         res.statuscode.should.equal(200);           should(data).not.null();         should(data.endpoint).not.undefined();         data.endpoint.should.equal('http://endpointyouhit:8080');           done();  }); 

yet file size on file system 0. i'm not using readstream correctly, i'm not sure how correct it. appreciated.

note want stream file, not load in memory on transmit , receive, file can potentially large in memory operation.

thanks, todd

one thing need specify content-type of multi-part/form-data. however, looks restify doesn't support content type, you're out of luck using restify client post file.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -