how to use request module to download, and then upload file without intermediate file

后端 未结 2 894
时光说笑
时光说笑 2021-01-22 18:57

I want to download a image file to server first, then upload this file to other server.

If there is no download file step, it will be very simple



        
2条回答
  •  死守一世寂寞
    2021-01-22 19:37

    Following the request documentation, you can use

    request.get(sourceUrl).pipe(request.post(targetUrl))
    

    in this scheme, the data will flow from sourceUrl to targetUrl but will not need to be saved in a temporary file on the server.

    cf https://github.com/request/request#streaming for more details.

提交回复
热议问题