Swift

Getting started

https://docs.openstack.org/swift/latest/

Basic commands

swift help: get help!

swift subcommand --help: get help for a subcommand

swift post foo: creates a container (bucket)

swift upload foo myfile.txt: upload a file in foo container

swift upload foo mydir/: upload the directory, recursively

swift upload foo a/path/to/a/file --object-name file: specify the remote path/name of the file

swift stat foo: get metadata for container or file

swift delete foo file: delete a file from a container

swift delete foo: delete a container and all its data

Permissions on containers

https://docs.openstack.org/swift/latest/overview_acl.html

When creating/updating a container you can define permissions using the -r / -w options:

  • swift post foo -r ".r:*,.rlistings,": global read/list access (r for referer, .rlistings limite les droits de lister)
  • swift post foo -r 'tenant_id_here:*,other_tenant_id_here:user_id_in_tenant': keystone tenant/user access

Metadata

You can associate key/value metadata with files and containers (-m option). They can be arbitrary, but some keys are meaningfull to swift (see “Static Website” for examples).

Advanced features

Object expiration

It is possible to automatically delete object at a certain date or after a period of time:

swift upload -H 'X-Delete-On: 150000000' container file: Delete at (UTC)

swift upload -H 'X-Delete-After: 3600' container file: Delete after seconds

Temporary URLs

https://community.runabove.com/kb/en/object-storage/Sharing-an-object-with-temp-url-system.html

Static website

https://docs.openstack.org/swift/latest/middleware.html#staticweb

swift post -r ".r:*,.rlistings" \
    -m "Web-Listings: true" \
    -m "Web-Listings-CSS: style.css" \
    -m "Web-Index: index.html" \
    website
cd website
swift upload website *