http: media-type:multipart / for
2018-12-28 本文已影响3人
BenjaminCool
- 如果表单包含文件上传,则使用multipart / form-data,否则使用application / x-www-form-urlencoded,如果省略enctype,则默认为默认值。
So after that initial set of headers follows the request body
https://ec.haxx.se/http-multipart.html
--------------------------d74496d66958873e
Content-Disposition: form-data; name="person"
anonymous
--------------------------d74496d66958873e
Content-Disposition: form-data; name="secret"; filename="file.txt"
Content-Type: text/plain
contents of the file
--------------------------d74496d66958873e--
3. 如何读取请求body:
https://stackoverflow.com/questions/9081079/rest-http-post-multipart-with-json
--HereGoes
Content-Disposition: form-data; name="myJsonString"
Content-Type: application/json
{"foo": "bar"}
--HereGoes
Content-Disposition: form-data; name="photo"
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
<...JPEG content in base64...>
--HereGoes--
4. 上传多张图片
https://hellokoding.com/uploading-multiple-files-example-with-spring-boot/
5. 上传多张图片和json
https://www.mkyong.com/spring-boot/spring-boot-file-upload-example-ajax-and-rest/