aws-sdk-kotlin
aws-sdk-kotlin copied to clipboard
Introduce functionality to wrap a InputStream as a ByteStream
Describe the feature
I propose adding an easy way to convert a java.io.InputStream to a ByteStream to the library for the java target.
It might be worth considering a easy conversion from java.nio.Channel or kotlinx.io.Source as well, however both of these provide conversions for InputStream so at the very least InputStream should be considered.
Is your feature request related to a problem?
I recently tried to switch from the java sdk to kotlin sdk for s3 and hit a wall. With the java sdk, I pass an input stream to a putObject or uploadPart request, but there doesn't seem to be an equivalent right now in the kotlin sdk. I saw an issue, that converts from ByteStream to InputStream, but not the other way.
The reason that I use streams is to avoid loading large amounts of data into memory. Occasionally, I need to load large files into s3 and pulling the whole file or part into memory would take up a significant amount of memory. Using streams allows me to be more efficient with memory and take on a lot more requests for less memory.
Proposed Solution
After a cursory glace at the code, my guess is we need to provide some kind of implementation of ByteStream.ChannelStream() to support input streams. On top of that it would be super useful to provide a extension function on inputstream to make the conversion.
Describe alternative solutions or features you've considered
No response
Acknowledge
- [ ] I may be able to implement this feature request
AWS SDK for Kotlin version
1.2.47
Platform (JVM/JS/Native)
JVM
Operating system and version
Linux 6.9.7