AWS CLI commands to manage your DreamObjects data

 

Overview

You can use AWS CLI commands to create, list, upload, download, share, and delete objects in your DreamObjects buckets. Before you begin, install and configure the AWS CLI using the following article:

This article contains the following examples:

In the following examples, username would be your Shell user and example.com your website.

Creating

How do I make a bucket?

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 mb s3://newbucketname --region us-east-005
make_bucket: s3://newbucketname/

Listing

How do I list all buckets under a user?

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 ls
2024-04-08 20:14:46 newbucketname

How do I list the contents of a specific bucket?

Use the following flags to display data about the size of your Objects.

  • --recursive
  • --human-readable
  • --summarize

View the ls page for further options:

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 ls --recursive --human-readable --summarize s3://my-bucket/
2024-04-08 12:37:51    0 Bytes backups/
2024-04-08 11:43:16  107.1 MiB backups/example.com/02-03-2020_example.com.zip
2024-04-08 11:43:04   70.2 KiB backups/example.com/02-03-2020_example_co_1.sql
2024-04-08 12:36:25    3.9 KiB test.txt

Total Objects: 4
   Total Size: 107.2 MiB

Uploading

You can use either the cp or sync command to upload files and directories. The difference is that cp will overwrite any existing file or directory with the same name, while the sync command will only upload new or changed files.

How do I upload a single file?

Copying a file

This copies a file named file.txt to your bucket. Make sure to also specify the same name of the file within the bucket file-path. 

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 cp /home/username/file.txt s3://my-bucket/file.txt

How do I upload a directory?

When uploading a directory, make sure to add the directory name to the s3 file path in your command. For example:

s3://my-bucket/my-directory

If you do not add the directory path you wish to upload to, the contents of the directory you're uploading will be placed in the bucket's top-level directory.

How do I use the cp command?

Use the --recursive flag to copy a directory and any subdirectories.

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 cp /home/username/my-directory s3://my-bucket/my-directory --recursive

How do I use the sync command?

This uploads all contents of a directory to your DHO bucket. Subdirectories will only be uploaded if they are not empty.

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 sync /home/username/my-directory s3://my-bucket/my-directory

Downloading

How do I download a file from a bucket?

Make sure to specify at the end, the path and name of the file to be downloaded.

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 cp s3://my-bucket/file.txt /home/username/file.txt

How do I download a directory from a bucket?

Make sure to specify at the end, the path and directory of the bucket directory to be downloaded. You must also use the --recursive flag for a directory.

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 cp s3://my-bucket/download-directory /home/username/download-directory --recursive

Sharing

How do I share a single file?

Objects in public buckets can be shared directly, but objects in private buckets must include a URL that has been specifically generated to share them.

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 presign /home/username/file.txt s3://my-bucket/file.txt --expires-in 604800
https://s3.us-east-005.dream.io/my-bucket/file.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=0054b7DPjPZlKpYoUARPQAjvm%2F20251115%2Fus-east-5%2Fs3%2Faws4_request&X-Amz-Date=20251115T001107Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=20jKpLX22oEgCjNZaczGSa0RaOyc0DjIumN7pt7c961tDvFxB8oUdI8xCXDOeixse

Deleting

How do I delete an object in a bucket?

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 rm s3://my-bucket/file.txt

How do I delete all files and directories in a bucket?

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 rm s3://my-bucket/ --recursive

How do I delete an empty bucket?

[user@localhost]$ aws --endpoint-url https://s3.us-east-005.dream.io s3 rb s3://mybucket/

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?