Closed dronda-t closed 4 months ago
Thanks for the feature request @dronda-t, we'll take a look at prioritizing it soon!
Your submission mentions working with large files and it's worth noting that the existing File.asByteStream()
and Path.asByteStream()
functions already allow working with files in a streaming fashion and do not load entire files into memory. I realize they're tied specifically to files and not other forms of arbitrary streaming data but it may still provide some benefit for your use case.
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
This feature has been merged into smithy-kotlin/main and aws-sdk-kotlin/main and should be available in the next SDK release, tentatively scheduled for Thursday, July 18.
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
AWS SDK for Kotlin version
1.2.47
Platform (JVM/JS/Native)
JVM
Operating system and version
Linux 6.9.7