0
votes

I have problem with Feign client. I need to send one file only and I don't want to use multipart MIME type(as I think it is not neccessary for one file). I can do it by creating encoder to byte array, but I would like to use some stream.

How can I write Feign encoder which will accept some java stream and will send it without buffering the file data into memory. Is it even possible with Feign client to do such binary transfers?

I have seen some example which used MultiPartFile, which used "multipart/form-data", but I don't want to use multipart.

Is it possible to write such a Feign encoder?

UPDATE Is it at all possible to send binary data by Feign without the data being buffered into byte array. According to this it is not.

1

1 Answers

-1
votes

That is actually pretty straigh forward. Just use byte[] as parameter.

public interface PostAPI {
    @RequestLine("POST /post")
    @Headers({
            "Content-Type: application/octet-stream",
            "Accept: text/plain"
    })
    String length(byte[] blob);
}

I choose a String as return value but you can return whatever you like.