Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
新方案:
增加
receive
方法,通过receive
方法将post的数据进行处理,并放到request.body
中。方案示例如下:
POST的数据为:
结果是:
对于
multipart/form-data
的数据,则可以使用如下方法进行处理:获得的数据:
可见post的图片被转换成了buffer。
大多数情况下并不需要对post来的文件直接进行处理,而是进行保存,所以提供了一个
saveAs
参数,如:上述2个方案是等价的,不过必须保证readable下有name属性
这样上传之后,文件会被保存在对应的位置(通过管道的方式,因此不会占用过多的内存),这样得到的结果中不会有
content
而是被saveAs
取代,saveAs
中是保存的最终位置:兼容的方式
已经和上一版进行兼容,选择对于urlencoded的数据,可以直接用
this.request.body
获取到数据。