AWS CLI commands to manage your DreamObjects data

Overview

This article lists several aws-cli commands you can use to manage your DreamObjects data. View the following article for information on how to install and configure AWS CLI:

This article contains the following examples:

Creating

Making a bucket

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

Listing

Listing all buckets under a user

[user@localhost]$ aws --endpoint-url https://objects-us-east-1.dream.io s3 ls
2019-01-31 20:14:46 newbucketname

Listing 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://objects-us-east-1.dream.io s3 ls --recursive --human-readable --summarize s3://my-bucket/
2020-01-30 12:37:51    0 Bytes backups/
2020-02-03 11:43:16  107.1 MiB backups/example.com/02-03-2020_example.com.zip
2020-02-03 11:43:04   70.2 KiB backups/example.com/02-03-2020_example_co_1.sql
2020-02-03 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. The sync command will only upload new or changed files

Uploading 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://objects-us-east-1.dream.io s3 cp /home/user/file.txt s3://my-bucket/file.txt

Uploading 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.

Using the cp command 

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

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

Using 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://objects-us-east-1.dream.io s3 sync /home/username/my-directory s3://my-bucket/my-directory

Downloading

Downloading 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://objects-us-east-1.dream.io s3 cp s3://my-bucket/file.txt /home/user/file.txt

Downloading 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://objects-us-east-1.dream.io s3 cp s3://my-bucket/download-directory /home/user/download-directory --recursive

Deleting

Deleting an object in a bucket

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

Deleting all files and directories in a bucket

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

Deleting an empty bucket

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

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?