Skip to content

AWS CLI

The AWS CLI works with Hive Buckets. You need an access key.

Terminal window
aws configure --profile dockhive
# AWS Access Key ID: DH...
# AWS Secret Access Key: <your secret>
# Default region name: auto
# Default output format: json
aws configure set s3.addressing_style path --profile dockhive

Point every command at the endpoint with --endpoint-url, or save it in the profile (AWS CLI 2.13 and later) so you can leave it out:

~/.aws/config
[profile dockhive]
region = auto
endpoint_url = https://s3.dockhive.io
s3 =
addressing_style = path
multipart_threshold = 64MB
multipart_chunksize = 16MB

The examples below assume export AWS_PROFILE=dockhive and pass --endpoint-url for clarity.

Terminal window
EP=https://s3.dockhive.io
# Upload a file and a folder
aws s3 cp ./report.pdf s3://my-app-uploads/reports/report.pdf --endpoint-url $EP
aws s3 cp ./images s3://my-app-uploads/images/ --recursive --endpoint-url $EP
# List
aws s3 ls --endpoint-url $EP # your buckets
aws s3 ls s3://my-app-uploads/reports/ --endpoint-url $EP
# Download
aws s3 cp s3://my-app-uploads/reports/report.pdf . --endpoint-url $EP
# Mirror a folder (only changed files are sent; --delete removes files that are gone locally)
aws s3 sync ./public s3://my-app-assets/ --delete --endpoint-url $EP
# Delete
aws s3 rm s3://my-app-uploads/reports/report.pdf --endpoint-url $EP
aws s3 rm s3://my-app-uploads/tmp/ --recursive --endpoint-url $EP
# Share a file for one hour
aws s3 presign s3://my-app-uploads/reports/report.pdf --expires-in 3600 --endpoint-url $EP

aws s3 cp and aws s3 sync switch to multipart uploads for large files automatically. Keep multipart_chunksize at 100 MB or less; the default of 8 MB is fine. See Limits.

aws s3api exposes individual S3 operations:

Terminal window
# Object details and tags
aws s3api head-object --bucket my-app-uploads --key reports/report.pdf --endpoint-url $EP
aws s3api put-object-tagging --bucket my-app-uploads --key reports/report.pdf \
--tagging 'TagSet=[{Key=team,Value=finance}]' --endpoint-url $EP
# Create a bucket (needs an Admin key for all buckets)
aws s3api create-bucket --bucket my-new-bucket --endpoint-url $EP
# Turn on versioning (needs an Admin key)
aws s3api put-bucket-versioning --bucket my-app-uploads \
--versioning-configuration Status=Enabled --endpoint-url $EP
aws s3api list-object-versions --bucket my-app-uploads --prefix reports/ --endpoint-url $EP

More s3api examples are on the CORS, versioning, bucket policy and lifecycle pages.

Tools such as rclone, s3cmd, Cyberduck and restic work too. Use the same settings everywhere: endpoint https://s3.dockhive.io, region auto, path-style addressing, and your DH... access key.