我有这个http请求来上传图像(application / octet-stream)。我不知道如何从服务器端(java spring servlet)接收此应用程序/八位字节流。 我试着这样做
request.getPart("ax_file_input");
但我得到了空。
以下是请求:
部首:
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8,zh-TW;q=0.6,zh;q=0.4,ja;q=0.2
Connection:keep-alive
Content-Length:27530
Content-Type:multipart/form-data; boundary=---- WebKitFormBoundarymuhts7ls9NLoqkUW
请求有效负载:
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-max-file-size"
10485760
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-thumbPostfix"
_thumb
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-thumbHeight"
0
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-thumbWidth"
0
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-file-size"
25896
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-file-name"
avatar3.png
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax_file_input"; filename="blob"
Content-Type: application/octet-stream
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-start-byte"
0
------WebKitFormBoundarymuhts7ls9NLoqkUW
Content-Disposition: form-data; name="ax-file-md5"
------WebKitFormBoundarymuhts7ls9NLoqkUW--
答案 0 :(得分:1)
Apache commons fileupload可用于解析多部分请求(这是您上传文件所需的)。
这里有一个例子: http://codingitforward.blogspot.com/2010/01/java-upload-servlet.html