2

I am trying to find a simple way to use Feign to download a csv file (retaining the filename).

What is the easiest and cleanest way?

The multipart solution on the feign-form github page is verbose and isn't working for me.

Any help is appreciated.

user12722869
  • 21
  • 1
  • 1
  • 2

1 Answers1

8

Feign client:

import feign.Response;

@FeignClient(value = "some-service")
public interface Client{
   @RequestMapping(method = RequestMethod.GET, value ="/download")
   Response downloadFile();
}

Usage of Feign Client:

final Response response = client.downloadFile();
final Response.Body body = response.body();
final InputStream inputStream = body.asInputStream();

You should check if response is 200, if not, throws exception. File name should be in headers

kev
  • 81
  • 3