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

aws s3 cp from stdin #769

Closed
bukzor opened this issue May 8, 2014 · 2 comments
Closed

aws s3 cp from stdin #769

bukzor opened this issue May 8, 2014 · 2 comments
Labels
feature-request A feature should be added or improved. s3

Comments

@bukzor
Copy link

bukzor commented May 8, 2014

I'd like to upload a tarball to s3 without incurring the cost of a temporary file (we're low on disk). With other utilities, I'd pipe the output of the tar command to the uploading command, but it doesn't Just Work with aws-cli:

$ echo ok | aws s3 cp /dev/stdin s3://my-bucket/test
upload failed: /dev/stdin to s3://my-bucket/test [Errno 29] Illegal seek

It seems like this simple curl script works however:

#!/bin/bash
configfile="aws.ini"
file="/test"
bucket="my-bucket"
resource="/${bucket}${file}"
contentType="application/x-compressed-tar"

# Grab the config values
eval $(cat aws.ini  | grep -P "^\w+=[-'/\w]+$")

# Calculate the signature.
dateValue=$(date -R)
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}"
signature=$(echo -en ${stringToSign} | openssl sha1 -hmac ${aws_secret_access_key} -binary | base64)

# PUT!
curl \
    -X PUT \
    --data @- \
    -H "Host: ${bucket}.s3.amazonaws.com" \
    -H "Date: ${dateValue}" \
    -H "Content-Type: ${contentType}" \
    -H "Authorization: AWS ${aws_access_key_id}:${signature}" \
    "https://${bucket}.s3.amazonaws.com${file}"

Can we please get similar capability in aws s3 cp?

@bukzor
Copy link
Author

bukzor commented May 9, 2014

The other direction doesn't have this issue; I can force aws-cli to use stdout with:

aws s3 cp s3://my-bucket/test >(cat)

It would be better if it followed the usual unix "-" convention though.

@kyleknap
Copy link
Contributor

Feature added via #903. Closing the issue.

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. s3
Projects
None yet
Development

No branches or pull requests

3 participants