Skip to content

Commit

Permalink
multipart: send content-length in POST requests (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadmeste authored and harshavardhana committed Jan 17, 2017
1 parent 2e5ebde commit 5574f30
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api/src/main/java/io/minio/MinioClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,11 @@ private HttpResponse execute(Method method, String region, String bucketName, St
if (headerMap != null) {
contentType = headerMap.get("Content-Type");
}
if (body != null && !(body instanceof InputStream || body instanceof RandomAccessFile || body instanceof byte[])) {
byte[] bytes = body.toString().getBytes(StandardCharsets.UTF_8);
body = bytes;
length = bytes.length;
}

Request request = createRequest(method, bucketName, objectName, region,
headerMap, queryParamMap,
Expand Down Expand Up @@ -2490,7 +2495,7 @@ private void setBucketPolicy(String bucketName, BucketPolicy policy)

String policyJson = policy.getJson();

HttpResponse response = executePut(bucketName, null, headerMap, queryParamMap, policyJson, policyJson.length());
HttpResponse response = executePut(bucketName, null, headerMap, queryParamMap, policyJson, 0);
response.body().close();
}

Expand Down

0 comments on commit 5574f30

Please sign in to comment.