googleapis / googleapis/java-storage

Support `InputStream` as a source of `RequestBody`

Open
#3,554 0 comments 0 reactions 0 assignees View on GitHub
api: storage
Dominant language
Java
Stars
141
Forks
93
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
Currently `RequestBody` can only be constructed from `ByteBuffer`. If a caller wants to supply data from an `InputStream` this API forces an allocation and copy of the data in the stream into an intermediate buffer.

**Describe the solution you'd like**
I would like to be able to create `RequestBody` from an `InputStream`. It seems that `mark` and `reset` functionality can be used to implement rewinding in `RewindableContent`.

**Describe alternatives you've considered**
I can use an intermediate buffer solution and it works but it's not ideal.

Contributor guide

Open the contributing guide

Research direction

Start by locating the RequestBody construction API and the RewindableContent implementation, then compare how the existing ByteBuffer source is handled. Determine the required mark/reset behavior for an InputStream and verify that the new source avoids the intermediate copy while remaining rewindable.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.