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

s3-credentials put-object and s3-credentials get-object commands #38

Closed
simonw opened this issue Nov 30, 2021 · 7 comments
Closed

s3-credentials put-object and s3-credentials get-object commands #38

simonw opened this issue Nov 30, 2021 · 7 comments
Labels
enhancement New feature or request
Milestone

Comments

@simonw
Copy link
Owner

simonw commented Nov 30, 2021

I'd like to be able to use this tool to easily upload and download from the S3 buckets, without having to switch to (and install) a a separate tool.

@simonw simonw added the enhancement New feature or request label Nov 30, 2021
@simonw
Copy link
Owner Author

simonw commented Nov 30, 2021

Design for put-object:

s3-credentials put-object my-bucket my-pictures/panda.jpg panda.jpg

Or:

echo "Content" | s3-credentials put-object my-bucket my-key.txt -

@simonw
Copy link
Owner Author

simonw commented Nov 30, 2021

For get-object:

s3-credentials get-object my-bucket my-key.txt # Outputs to standard output

Or:

s3-credentials get-object my-bucket my-key.txt -o file.txt

@simonw
Copy link
Owner Author

simonw commented Nov 30, 2021

Maybe in the future add --acl to put-object - from the boto docs:

ACL='private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control'

@simonw
Copy link
Owner Author

simonw commented Nov 30, 2021

Tried this:

@cli.command()
@click.argument("bucket")
@click.argument("key")
@click.argument("body", type=click.File("rb"))
@common_boto3_options
def put_object(bucket, key, body, **boto_options):
    "Upload an object to an S3 bucket"
    s3 = make_client("s3", **boto_options)
    response = s3.put_object(Body=body, Bucket=bucket, Key=key)
    click.echo(json.dumps(response, indent=4, default=str))

And got this error:

 % echo "Hello world" | s3-credentials put-object static.niche-museums.com hello.txt -
Traceback (most recent call last):
...
  File "/Users/simon/.local/share/virtualenvs/s3-credentials-J8M1ChYK/lib/python3.10/site-packages/botocore/utils.py", line 2434, in _calculate_md5_from_file
    start_position = fileobj.tell()
OSError: [Errno 29] Illegal seek

@simonw
Copy link
Owner Author

simonw commented Nov 30, 2021

I should use this module, it handles lots of interesting extra features, including progress bars: https://github.com/boto/boto3/blob/c5487b57499ad354e24ca2c8622f90fe089240b6/boto3/s3/transfer.py

@simonw
Copy link
Owner Author

simonw commented Nov 30, 2021

I'm going to test these as part of the existing integration tests.

@simonw simonw closed this as completed in 46b6531 Nov 30, 2021
simonw added a commit that referenced this issue Nov 30, 2021
@simonw simonw added this to the 1.0 milestone Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant