WookjeBlog
    • 블로그
    • 소개
    • 태그
    • 수업/강의
    • 라이브러리
    Main
    • Share to Facebook

    REST

    All Posts in rest

    • Kotlin에서 ByteArray를 MultipartFile로 post하기

      val file = object : ByteArrayResource(byteArray) { override fun getFilename(): String { return "tempFileName.ext" } } val headers = HttpHeaders() headers.contentType = MediaType.MULTIPART_FORM_DATA val body: MultiValueMap<String, Any> = LinkedMultiValueMap() body.add("file", file) val requestEntity = HttpEntity(body, headers) val response = restTemplate.exchange(uri, HttpMethod.POST, requestEntity, object : ParameterizedTypeReference<String?>() {}) 구현체를 못 봐서 정확히는 모르지만, 추측하자면 MultiparFile의 interface에는 getResource()가 정의되어 있고, Resource 타입의 객체를 리소스로서 들고 있는 것 같다. ByteArrayResource는 Resource를 조상 클래스로 두고 있는, ByteArray를 리소스로 관리하는 클래스이므로...

      kotlin http rest

      wookje.kwon's profile image

      wookje.kwon

      2020-07-16 22:32

    • github
    • facebook
    • rss

    Copyright © Wookje Kwon. All rights reserved.