Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ possible, but it is not implemented here.

1. Download the [s3simple](s3simple) script somewhere.
2. Set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` and optionally
`AWS_SESSION_TOKEN` environment variables.
`AWS_SESSION_TOKEN` and `S3_SERVER` environment variables.
3. Run `s3simple` with a method, an `s3://` url and, optionally, a local
filename.

Expand All @@ -32,6 +32,8 @@ For example:
export AWS_SECRET_ACCESS_KEY=zzzz
# optionally provide a temporary session token
export AWS_SESSION_TOKEN=wwww...
# optionally provide an S3 server address
export S3_SERVER=http://my-s3.example.com:9000

# get a file
./s3simple get s3://mybucket/myfile.txt myfile.txt
Expand Down
7 changes: 6 additions & 1 deletion s3simple
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ s3simple() {
local bucket="${path%%/*}"
local key="${path#*/}"

curl "${args[@]}" -s -f -H "Date: ${date}" -H "Authorization: ${authorization}" "https://${bucket}.s3.amazonaws.com/${key}"
local url="https://${bucket}.s3.amazonaws.com"
if [ -n "${S3_SERVER-}" ]; then
url="${S3_SERVER}/${bucket}"
fi

curl "${args[@]}" -s -f -H "Date: ${date}" -H "Authorization: ${authorization}" "${url}/${key}"
}

s3simple "$@"