How to buffer an HTTP response using the request module?

前端 未结 4 868
清酒与你
清酒与你 2021-02-01 18:52

I would like to stream the contents of an HTTP response to a variable. My goal is to get an image via request(), and store it in in MongoDB - but the image is alway

4条回答
  •  没有蜡笔的小新
    2021-02-01 19:14

    Have you tried piping this?:

    request.get('http://google.com/doodle.png').pipe(request.put('{your mongo path}'))
    

    (Though not familiar enough with Mongo to know if it supports direct inserts of binary data like this, I know CouchDB and Riak do.)

提交回复
热议问题