Zum Inhalt springen

Basic Operations Object Storage

Diese Seite ist noch nicht in deiner Sprache verfügbar. Englische Seite aufrufen

To create a new bucket use the make bucket (mb) command. The bucket name hast to start with s3://.

In this example the bucket s3://my-example-bucket will be created. If it was successful, you will see this output:

$ s3cmd mb s3://my-example-bucket
Bucket 's3://my-example-bucket/' created

To list all existing buckets, you can use the ls command.

$ s3cmd ls
2021-12-01 10:20 s3://my-example-bucket

If you want to list all files in a bucket, you add the bucket name as an additional argument. In the following output you can see that there is one file in the my-example-bucket bucket.

$ s3cmd ls s3://my-example-bucket/
2021-12-01 10:39 27 s3://my-example-bucket/testfile.txt

The bucket deletion works analog to the creation. But instead of the mb command you use the remove bucket (rb) command.

In this example the bucket s3://my-example-bucket will be deleted. This will take about 10 seconds. If it was successful you will see this output:

$ s3cmd rb s3://my-example-bucket
Bucket 's3://my-example-bucket/' removed

To upload files into a bucket use the put command. You have to add the filename and the bucket name as parameters.

In this example the file testfile.txt is uploaded to the bucket s3://my-example-bucket.

$ s3cmd put testfile.txt s3://my-example-bucket
upload: 'testfile.txt' -> 's3://my-example-bucket/testfile.txt' [1 of 1]
27 of 27 100% in 0s 1829.89 B/s done

If you want to delete a file from your bucket you need to specify the delete (del) command. But after the bucket name you need to specify the file you want to delete. In this example testfile.txt will be deleted. If it was successful you will see this output:

$ s3cmd del s3://my-example-bucket/testfile.txt
delete: 's3://my-example-bucket/testfile.txt