How to send files with superagent

前端 未结 4 851
南笙
南笙 2021-01-03 03:46

So about a month ago I asked a question regarding superagent and sending files, but got no response at all. I would still like to find out how to do this as I enjoy using su

4条回答
  •  被撕碎了的回忆
    2021-01-03 04:31

    This should work.

    var file = this.refs.File.getDOMNode().files[0];
    
    
    Request.post('http://localhost:8080/files')
        .set("Content-Type", "application/octet-stream")
        .send(file)
        .end((err, res) => {
            console.log(err);
            console.log(res);
        })
    

提交回复
热议问题