Downloading objects

Once objects have been uploaded to a container, one may also want to download them. In this recipe, we will show you how to download objects to your local disk.

Getting ready

Ensure that you are logged on to a correctly configured OpenStack client and can access the OpenStack environment as a user with the swiftoperator privileges. We will use the developer user created in the Common OpenStack identity tasks recipe in Chapter 2, The OpenStack Client with the cookbook4 password. We have also granted this user the swiftoperator privileges.

Refer to Chapter 2, The OpenStack Client, for details of setting up your environment to use the OpenStack command-line client.

How to do it…

To download objects from a Swift cluster, carry out the following steps:

  1. List the available objects in a container:
    openstack object list books
    

    This will give a list of objects in our books container:

    How to do it…
  2. To download the desired file, for example, intro.txt, issue the following command:
    openstack object save books intro.txt
    

    Note

    There is no output to this command. The file will be saved to the current directory.

  3. We can also download a file and specify the destination file:
    openstack object save books nova.txt --file /tmp/nov
    a.txt
    

How it works…

In order to download files from the OpenStack Object Storage, issue the following command:

openstack object save container object --file file_name

The --file flag is optional. If not specified, the object will be saved to the current directory.

Note

Large objects do not require special treatment when downloading; the same command will work on large and small objects.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.58.122