Skip to content

Commit c207dd8

Browse files
authored
Merge pull request #1097 from sjpark-dev/mime-type-to-blob-content
feat: add mime type to blob content
2 parents d0b3a7b + 54e7826 commit c207dd8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clients/line-bot-client-base/src/main/java/com/linecorp/bot/client/base/BlobContent.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
import java.io.IOException;
2020
import java.io.InputStream;
21+
import java.util.Objects;
2122

23+
import okhttp3.MediaType;
2224
import okhttp3.ResponseBody;
2325

2426
public class BlobContent {
@@ -41,4 +43,12 @@ public InputStream byteStream() {
4143
public String string() throws IOException {
4244
return responseBody.string();
4345
}
46+
47+
/**
48+
* Returns the content type of the response.
49+
*/
50+
public String mimeType() {
51+
MediaType contentType = Objects.requireNonNull(responseBody.contentType());
52+
return contentType.toString();
53+
}
4454
}

clients/line-bot-messaging-api-client/src/test/java/com/linecorp/bot/messaging/client/MessagingApiBlobClientExTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void getMessageContent() throws IOException {
103103
stubFor(get(urlEqualTo("/v2/bot/message/aaaa/content")).willReturn(
104104
aResponse()
105105
.withStatus(200)
106-
.withHeader("content-type", "application/octet-stream")
106+
.withHeader("content-type", "image/jpeg")
107107
.withHeader("x-line-request-id", "ppp")
108108
.withBody("JPG]]]]]]")));
109109

@@ -114,6 +114,7 @@ public void getMessageContent() throws IOException {
114114
// Verify
115115
assertThat(result.requestId()).isEqualTo("ppp");
116116
assertThat(requireNonNull(result.body()).string()).isEqualTo("JPG]]]]]]");
117+
assertThat(requireNonNull(result.body().mimeType())).isEqualTo("image/jpeg");
117118
}
118119

119120
@Test

0 commit comments

Comments
 (0)