question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating RequestBody from an InputStream

See original GitHub issue

I was looking at RequestBody.java and I can’t find an overload for create() like this:

RequestBody.create(MediaType contentType, InputStream stream)'

Is there a reason not to implement this? This is pretty useful when piping from one stream into an upload job. The overload accepting a File is useful for files but that’s not the only scenario where buffering in memory does not work.

Please shed some lights if I’m missing something. Thanks!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
Ulanxxcommented, Jan 17, 2017

Course of project , i need the overload , do you find answers?

3reactions
bpappincommented, Jul 30, 2018

Handling files on Android is not nice at all, so we need to use content:// URIs. We can get a streams from them, or File Descriptors, but not a file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to POST InputStream as the body of a request in Retrofit?
You can upload inputStream using Multipart . @Multipart @POST("pictures") suspend fun uploadPicture( @Part part: MultipartBody.Part ): NetworkPicture.
Read more >
RequestBody supports InputStream · Issue #3585 ... - GitHub
I would like to submit a PR to add support for InputStream s in the RequestBody class. As of now, RequestBody supports the...
Read more >
InputStreamRequestBody (parent 4.2.0 API)
Creates the @link RequestBody from an @link InputStream . Parameters: mediaType - the media type: inputStream - the input stream ...
Read more >
RequestBody (AWS SDK for Java - 2.18.38) - Amazon AWS
Creates a RequestBody from an input stream. "Content-Length" must be provided so that the SDK does not have to make two passes of...
Read more >
com.squareup.okhttp.RequestBody.create java code examples
private static RequestBody createRequestBody(Request r) throws AuthFailureError { final byte[] body = r.getBody(); if (body == null) return null; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found