Home > openstack > Accessing OpenStack Swift object store with Curl command

Accessing OpenStack Swift object store with Curl command

In spite of  having very nice examples on accessing object store with curl [1], here I would like to rephrase some of them here for my knowledge keeping in this blog.

In my settings, my objects storage is configured with tempauth which I have described in in tempauth. The curl commands are as follows:

> Authenticating with tempauth:

curl -v -H  “X-Auth-User:test:tester” -H  “X-Auth-Key:testing”  http://localhost/auth/v1.0/

> Set the endpoint & token:

export STORAGE_URL=http://localhost:8080/v1/AUTH_test
export TOKEN=AUTH_tk5328b8839a6e4a71aeec048542e4dc8b

or

export TOKEN=`keystone token-get | grep id | head -n 1 | awk ‘{print $4}’`

and

 

s_url=`keystone –os-username=admin –os-password=nova endpoint-list | grep AUTH_ | awk ‘{print $6}’ | sed ‘s/\$(tenant_id)s//’`

tenant_id=`keystone –os-username=admin –os-password=nova tenant-get $OS_TENANT_NAME | grep id | awk ‘{print $4}’`

export STORAGE_URL=$s_url$tenant_id

 

 

> Statistics of an Account:
curl -i $STORAGE_URL -X GET -H “X-Auth-Token:$TOKEN”

> Create a Container:
curl -i $STORAGE_URL/container1 -X PUT -H “X-Auth-Token:$TOKEN”

> stat of the container/listing of a container:
curl -i $STORAGE_URL/container1  -X GET -H “Content-Length: 0” -H “X-Auth-Token:$TOKEN”

>upload a object(photo.jpg inside container1):
curl -X PUT -i -H “X-Auth-Token: $TOKEN” -T photo.jpg $STORAGE_URL/container1/photo.jpg

> download a object:
curl -X GET -i  -H  “X-Auth-Token: $TOKEN”  $STORAGE_URL/container1/photo.jpg

or (if every one has the permission to read/download it)

wget $STORAGE_URL/steven/photo.jpg

References:

1. http://docs.openstack.org/api/openstack-object-storage/1.0/content/retrieve-copy-retrieve-objects.html

Advertisements
Categories: openstack Tags: , ,
  1. Rufael
    September 1, 2016 at 3:43 am

    finally some good examples

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: