问题:
--jSRKAk3FJXTrWcxiPofHkPefUfGXvS
Content-Disposition: form-data; name="fileName"; filename="fileName.pdf"
Content-Type: application/octet-stream
--wGvKUCX0qMYy2I_hutbHcUsaZubpm53D
Content-Disposition: form-data; name="fileName"; filename="fileName.pdf"
--wGvKUCX0qMYy2I_hutbHcUsaZubpm53D--
--jSRKAk3FJXTrWcxiPofHkPefUfGXvS--
结论:使用MultipartEntityBuilder构建时,
会给Request中的Head增加 Content-Disposition contentType
今后多文件上传时可能会用到,需要注意
MultipartEntityBuilder build2 = MultipartEntityBuilder.create();
build2.addBinaryBody(null, file);
解决:单文件上传时,使用EntityBuilder
不会给Request中的Head增加 Content-Disposition
它设置了contentType contentEncoding
EntityBuilder builder = EntityBuilder.create();
HttpEntity httpEntity = builder.setFile(file).build();