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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With