Skip to content

Create and manage objects in Object Storage

Last updated on

Objects are the individual files and data you store inside a bucket. You manage objects using the S3-compatible API through the AWS CLI or s5cmd.

Terminal window
aws s3 cp ./example.txt s3://my-bucket/ \
--endpoint-url https://object.storage.eu01.onstackit.cloud

The output confirms the upload:

upload: ./example.txt to s3://my-bucket/example.txt

To upload an entire directory recursively, use the --recursive flag:

Terminal window
aws s3 cp ./my-folder/ s3://my-bucket/my-folder/ --recursive \
--endpoint-url https://object.storage.eu01.onstackit.cloud
Terminal window
aws s3 cp s3://my-bucket/example.txt ./example.txt \
--endpoint-url https://object.storage.eu01.onstackit.cloud

The output confirms the download:

download: s3://my-bucket/example.txt to ./example.txt

To download an entire prefix recursively:

Terminal window
aws s3 cp s3://my-bucket/my-folder/ ./my-folder/ --recursive \
--endpoint-url https://object.storage.eu01.onstackit.cloud
Terminal window
aws s3 ls s3://my-bucket/ \
--endpoint-url https://object.storage.eu01.onstackit.cloud

The output lists the objects and their metadata:

2024-01-01 10:00:00 1024 example.txt
2024-01-02 11:30:00 20480 archive.zip

To list objects under a specific prefix or recursively across all prefixes, add --recursive:

Terminal window
aws s3 ls s3://my-bucket/my-folder/ --recursive \
--endpoint-url https://object.storage.eu01.onstackit.cloud
Terminal window
aws s3 rm s3://my-bucket/example.txt \
--endpoint-url https://object.storage.eu01.onstackit.cloud

The output confirms the deletion:

delete: s3://my-bucket/example.txt

To delete all objects under a prefix:

Terminal window
aws s3 rm s3://my-bucket/my-folder/ --recursive \
--endpoint-url https://object.storage.eu01.onstackit.cloud

Sync transfers only the files that differ between the source and destination, making it efficient for incremental backups and deployments.

Terminal window
aws s3 sync ./my-folder/ s3://my-bucket/my-folder/ \
--endpoint-url https://object.storage.eu01.onstackit.cloud

The output lists each file transferred:

upload: my-folder/file1.txt to s3://my-bucket/my-folder/file1.txt
upload: my-folder/file2.txt to s3://my-bucket/my-folder/file2.txt

To sync from the bucket back to a local directory:

Terminal window
aws s3 sync s3://my-bucket/my-folder/ ./my-folder/ \
--endpoint-url https://object.storage.eu01.onstackit.cloud