小程序-获取文件上传连接-uploadFile使用java客户端只能上传5kb以下的文件是为什么?
这个是上传超过5kb的文件返回的错误码
<Error>
<Code>MalformedPOSTRequest</Code>
<Message>The body of your POST request is not well-formed multipart/form-data.</Message>
</Error>
但是只要上传文件不大于5kb那么就能成功上传
2 回复
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("key",path);
objectObjectHashMap.put("Signature",weChatUpLoadResult.getAuthorization());
objectObjectHashMap.put("x-cos-security-token",weChatUpLoadResult.getToken());
objectObjectHashMap.put("x-cos-meta-fileid",weChatUpLoadResult.getCosFileId());
objectObjectHashMap.put("file",newFile);
objectObjectHashMap.put("url",weChatUpLoadResult.getUrl());
String body = HttpRequest.post(weChatUpLoadResult.getUrl())
.header(Header.CONTENT_TYPE, CONTENT_TYPE_MULTIPART_PREFIX + BOUNDARY, true)
.form(objectObjectHashMap)
.timeout(60000)
.execute()
.body();
log.info(body);
return objectObjectHashMap;
//只是涉及到一个简单的post请求,但是文件就是不能超过5kb左右