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

Add --input-stream option. #7

Merged
merged 8 commits into from
May 20, 2024
Merged

Add --input-stream option. #7

merged 8 commits into from
May 20, 2024

Conversation

fujiwara
Copy link
Owner

Add --input-stream option.

refs #6 Thanks for @mattn.

description

--input-stream option allows you to bind a file or stdin to the input struct.

$ aws-sdk-client-go s3 put-object '{"Bucket": "my-bucket", "Key": "my.txt"}' --input-stream my.txt

s3#PutObjectInput has Body field of io.Reader. --input-stream option binds the file to the field.

When the input struct has only one field of io.Reader, aws-sdk-client-go reads the file and binds it to the field automatically. (At now, all SDK input structs have only one field of io.Reader.)

When the input struct has a "*Length" field for the size of the content, aws-sdk-client-go sets the size of the content to the field automatically. For example, s3#PutObjectInput has ContentLength field.

If --input-stream is "-", aws-sdk-client-go reads from stdin. In this case, aws-sdk-client-go reads all contents into memory, so it is not suitable for large files. Consider using a file for large content.

@fujiwara fujiwara merged commit 40945ae into main May 20, 2024
4 checks passed
@fujiwara fujiwara deleted the input-bind branch May 20, 2024 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant