Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting stream content #218

Closed
1Cor125 opened this issue Feb 8, 2016 · 3 comments
Closed

Getting stream content #218

1Cor125 opened this issue Feb 8, 2016 · 3 comments
Labels

Comments

@1Cor125
Copy link

1Cor125 commented Feb 8, 2016

Just want to make sure I am not missing something here:
I have an API that has a few JSON endpoints but also a few endpoints with small binary files for download. If I expose the binary as a stream as in...
[Get("/v2/file.db.gz")] Task<Stream> GetFileAsync();
or as in...
[Get("/v2/file.db.gz")] Task<byte[]> GetFileAsync();
Refit wants to parse the result as JSON (which of course blows up).
I could get the raw response as in...
[Get("/v2/file.db.gz")] Task<HttpResponseMessage> GetFileAsync();
and then grab the stream or the bytes from response.Content in the caller.
Is this The Right Way?

@bennor
Copy link
Contributor

bennor commented Feb 8, 2016

As far as I'm aware, Task<HttpResponseMessage> is the only way at the moment. A PR for Task<byte[]> support would be pretty easy. 😉 (start here)

@bennor
Copy link
Contributor

bennor commented Feb 8, 2016

Nevermind. I overlooked the HttpContent support. If you set your return type Task<HttpContent>, you should be able to access the stream from the result.

@1Cor125
Copy link
Author

1Cor125 commented Feb 8, 2016

Thank you. That works well. I can get the bytes/stream without the extra overhead of the whole response.

@flagbug flagbug closed this as completed May 9, 2016
@MaxDeg MaxDeg mentioned this issue Aug 7, 2017
@lock lock bot added the outdated label Jun 25, 2019
@lock lock bot locked and limited conversation to collaborators Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants