Upload Files
Cloud Storage supports uploading objects with S3-compatible clients. This guide uses the AWS CLI; the same endpoint and credentials can be used with another S3-compatible SDK.
Before you start
- Create a bucket and note its name.
- Read your S3 access key and secret key.
- Get the S3 endpoint and region for your account from the Cloud Service console or your administrator.
The S3 endpoint is different from the Storage GraphQL gateway. Do not use the GraphQL gateway as the S3 endpoint.
Configure the AWS CLI
Install the AWS CLI, then set your credentials and region in the current shell:
export AWS_ACCESS_KEY_ID="your-access-key"
export AWS_SECRET_ACCESS_KEY="your-secret-key"
export AWS_DEFAULT_REGION="your-region"
export S3_ENDPOINT="https://your-s3-endpoint"
Replace the example values with the values for your account. Keep your secret key private and do not commit it to source control.
Upload an object
Use the bucket name and an object key (the path/name to give the uploaded file):
aws s3 cp ./photo.jpg "s3://your-bucket/photo.jpg" \
--endpoint-url "$S3_ENDPOINT"
To confirm the object is in the bucket:
aws s3 ls "s3://your-bucket/" --endpoint-url "$S3_ENDPOINT"
Objects are private or public according to the bucket's privacy settings. Avoid putting access keys in command history or scripts shared with others.