Skip to content

Commit 5574f30

Browse files
vadmesteharshavardhana
authored andcommitted
multipart: send content-length in POST requests (#490)
1 parent 2e5ebde commit 5574f30

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

api/src/main/java/io/minio/MinioClient.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,11 @@ private HttpResponse execute(Method method, String region, String bucketName, St
797797
if (headerMap != null) {
798798
contentType = headerMap.get("Content-Type");
799799
}
800+
if (body != null && !(body instanceof InputStream || body instanceof RandomAccessFile || body instanceof byte[])) {
801+
byte[] bytes = body.toString().getBytes(StandardCharsets.UTF_8);
802+
body = bytes;
803+
length = bytes.length;
804+
}
800805

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

24912496
String policyJson = policy.getJson();
24922497

2493-
HttpResponse response = executePut(bucketName, null, headerMap, queryParamMap, policyJson, policyJson.length());
2498+
HttpResponse response = executePut(bucketName, null, headerMap, queryParamMap, policyJson, 0);
24942499
response.body().close();
24952500
}
24962501

0 commit comments

Comments
 (0)