How to send files with superagent

前端 未结 4 852
南笙
南笙 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条回答
  •  -上瘾入骨i
    2021-01-03 04:39

    To complete previous answers and provide a reference, check this page: https://visionmedia.github.io/superagent/#multipart-requests

    According to it:

    When you use .field() or .attach() you can't use .send() and you must not set Content-Type (the correct type will be set for you).

    Also, even if this is not the case here, there are many posts/questions where people use the filename as the second argument for .attach. Again from this doc page:

    In browser create a Blob with an appropriate type instead.

    This doesn't refer to the second argument, but to a third 'options' one, but to me it implies that filenames are not supported in the browser version.

提交回复
热议问题