I want to upload InputStream to some URL, using BodyInserters.fromResource with code:

   WebClient.create()
            .put()
            .uri(URI.create(link))
            .body(BodyInserters.fromResource(new InputStreamResource(mimeMessage.getRawInputStream())))
            .header(HttpHeaders.CONTENT_TYPE, "application/my-content-type")

The main goal is to change the Content-Type header to something custom, but when I test that - I see that the url was requested with the application/octet-stream Content-Type. How to force WebClient to pick up my custom Content-Type?

My Spring Boot version 2.1.4.RELEASE

0 Answers