Skip to content

Commit 276286e

Browse files
balamuruganaharshavardhana
authored andcommitted
fix: send given byte array properly. (#491)
Previously if body parameter is a byte array, RequestBody.writeTo() sent empty byte array. This is fixed by typecasting body object into byte array properly.
1 parent dd4ca31 commit 276286e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,15 +684,14 @@ public long contentLength() {
684684

685685
@Override
686686
public void writeTo(BufferedSink sink) throws IOException {
687-
byte[] data = null;
688-
689687
if (body instanceof InputStream) {
690688
InputStream stream = (InputStream) body;
691689
sink.write(Okio.source(stream), length);
692690
} else if (body instanceof RandomAccessFile) {
693691
RandomAccessFile file = (RandomAccessFile) body;
694692
sink.write(Okio.source(Channels.newInputStream(file.getChannel())), length);
695693
} else if (body instanceof byte[]) {
694+
byte[] data = (byte[]) body;
696695
sink.write(data, 0, length);
697696
} else {
698697
sink.writeUtf8(body.toString());

0 commit comments

Comments
 (0)