Using mc with the object storage #
Configure mc #
Head over to minio’s website and download mc
(Minio Client) for your operating system:
https://min.io/download
mc
is a standalone tool and is available free of charge, and licensed using the AGPL. Configure mc
to use our object storage:
$ mc alias set pn-storage https://s3.storage.planetary-networks.de \
your-key-id \
your-secret-access-key
The above creates an alias called pn-storage
which you can use as a shorthand with mc
when you copy files from or to your buckets. Beware: it also saves the credentials along with it into ~/.mc
where you can inspect settings.
Using mc #
mc
is a nice command-line tool to help with day to day operations with the object storage.
Create a bucket #
A bucket is a namespace on the object storage, bucket names are globally unique and can be anything as long as it is DNS-compatible. We suggest to name your buckets after domains you own, for example: foo.example.org
.
Create a bucket with mc
:
$ mc mb pn-storage/{{ s3.bucket }}
Bucket created successfully `pn-storage/foo.example.org`.
Upload a file to a bucket #
In the following example we create a text file with the contents Hallo Welt and upload it to our bucket:
$ echo "Hallo Welt" > hello-world.txt
$ mc cp hello-world.txt pn-storage/foo.example.org/hello-world.txt.
hello-world.txt: 11 B / 11 B ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 441 B/s 0s
List the contents of a bucket #
$ mc ls pn-storage/foo.example.org
[2022-02-24 11:31:38 CET] 11B hello-world.txt.
Or, get a tree view - a pseudo directory listing:
β― mc tree pn-storage
pn-storage
ββ foo.example.org
Mirror (or copy) files #
To clone/upload an entire directory to the storage:
β― mc mirror ./local-directory pn-storage/foo.example.org
...something/something: 6.54 MiB / 6.54 MiB ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 1.03 MiB/s 6s
Make files public #
When using mc mirror
, mc cp
or mc sync
, you can supply an --attr
option to set a file policy to change the accessibility from its default (which is private).
As an example, in order to re-upload a local directory to the object storage and to force a public-read
policy on files contained, use the following as an example:
./mc mirror \
--attr x-amz-acl=public-read \
--overwrite \
--debug
./directory \
pn-storage/foo.example.org/
...
… among many other things.