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

Introduce functionality to wrap a InputStream as a ByteStream #1352

Closed
1 task
dronda-t opened this issue Jul 9, 2024 · 3 comments · Fixed by smithy-lang/smithy-kotlin#1121
Closed
1 task
Assignees
Labels
feature-request A feature should be added or improved.

Comments

@dronda-t
Copy link

dronda-t commented Jul 9, 2024

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

@dronda-t dronda-t added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 9, 2024
@ianbotsf
Copy link
Contributor

ianbotsf commented Jul 9, 2024

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.

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

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.

@ianbotsf
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
Development

Successfully merging a pull request may close this issue.

2 participants