API Quick Reference
- Administrators may create Containers to which Objects or files can be stored and retrieved. Admin users may grant and revoke container access to individual users.
- Non-admin users can only perform operations per container based on the container’s Read and Write ACLs. They are also restricted from listing containers.
Data from any of the commands included here (with the exception of authentication) may be requested in JSON format by specifying the format parameter: curl -H 'X-Auth-Token: AUTH_YourTokenHere' https://hcs.hwcdn.net/v1/AUTH_AccountName/?format=json
Create a Container
curl -X PUT -H 'X-Auth-Token: AUTH_YourTokenHere' https://hcs.hwcdn.net/v1/AUTH_AccountName/NameofContainer
Delete a Container
curl -X DELETE -H 'X-Auth-Token: AUTH_YourTokenHere' https://hcs.hwcdn.net/v1/AUTH_AccountName/NameofContainer
Note: that a container must be empty (no objects) in order to be successfully deleted.
List All Containers in Account
curl -H 'X-Auth-Token: AUTH_YourTokenHere' https://hcs.hwcdn.net/v1/AUTH_AccountName
Container Permissions
Permissions may be assigned on an individual basis or to multiple users at one time. In the latter instance, amend the command to include Account Users separated by commas.
Note: All objects in a container have the same permissions as the container itself; these cannot be customized.
Write Access
Write access allows the user to upload content to the specified container.
curl -v -X PUT -H 'X-Auth-Token: AUTH_YourTokenHere' -H 'X-Container-Write: AccountName:AccountUser' https://hcs.hwcdn.net/v1/AUTH_AccountName/NameofContainer
Read-Only Access
Read access allows the user to read the contents to the specified container.
curl -v -X PUT -H 'X-Auth-Token: AUTH_YourTokenHere' -H 'X-Container-Read: AccountName:AccountUser' https://hcs.hwcdn.net/v1/AUTH_AccountName/NameofContainer
List All Objects in a Container
curl -H 'X-Auth-Token: AUTH_YourTokenHere' https://hcs.hwcdn.net/v1/AUTH_AccountName/NameofContainer
Upload an Object to a Container
curl -v -T /home/you/FileName -X PUT -H 'X-Auth-Token: AUTH_YourTokenHere' https://hcs.hwcdn.net/v1/AUTH_AccountName/NameofContainer/
Download an Object from a Container
curl -H 'X-Auth-Token: AUTH_YourTokenHere' https://hcs.hwcdn.net/v1/AUTH_AccountName/NameofContainer/FileName
A file may be downloaded and saved locally by using the following command. Note that New File Name refers to the name you give the file to be saved locally.
curl -o NewFileName -H 'X-Auth-Token: AUTH_YourTokenHere' https://hcs.hwcdn.net/v1/AUTH_AccountName/NameofContainer/FileName
Delete an Object in a Container
curl -v -X DELETE -H 'X-Auth-Token: AUTH_YourTokenHere' https://hcs.hwcdn.net/v1/AUTH_AccountName/NameofContainer/FileName
Expanded API Examples
In this example, We are using the following sample credentials:
Account: sandboxaccount
User: sandboxuser
Password: sandboxpa55wd
This user sandboxuser
is an admin in sandboxaccount
.
Authentication Token Creation
The first step is to get an auth token. The uth tokens are usually good for up to 24 hours but may expire sooner under certain circumstances, such as a server restart. If you get a 401 error for a storage transaction later, it probably means your token expired and you'll have to do this again.
-[~:$]- curl -v -H 'X-Storage-User: sandboxaccount:sandboxuser' -H 'X-Storage-Pass: sandboxpa55wd' http://hcs.hwcdn.net/auth/v1.0
* About to connect() to hcs.hwcdn.net port 80 (#0)
* Trying 69.16.168.135...
* connected
* Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0)
> GET /auth/v1.0 HTTP/1.1
> User-Agent: curl/7.26.0
> Host: hcs.hwcdn.net
> Accept: */*
> X-Storage-User: sandboxaccount:sandboxuser
> X-Storage-Pass: sandboxpa55wd
>
< HTTP/1.1 200 OK
< X-Storage-Url: http://hcs.hwcdn.net/v1/AUTH_sandboxaccount
< X-Storage-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3
< X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3
< X-Trans-Id: txfcf4ac9293a243bf865ddacf3d132f91
< Content-Length: 0
< Date: Tue, 08 Jan 2013 17:57:24 GMT
<
* Connection #0 to host hcs.hwcdn.net left intact
* Closing connection #0
We want to note the X-Storage-Url and the X-Storage-Token for all storage-related transactions.
Listing Containers
In this case, we have one container in the account. And we have no objects
-[~:$]- curl -v -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount
* About to connect() to hcs.hwcdn.net port 80 (#0)
* Trying 69.16.168.135...
* connected
* Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0)
> GET /v1/AUTH_sandboxaccount HTTP/1.1
> User-Agent: curl/7.26.0
> Host: hcs.hwcdn.net
> Accept: */*
> X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3
>
< HTTP/1.1 200 OK
< X-Account-Object-Count: 0
< X-Timestamp: 1357668566.86607
< X-Account-Bytes-Used: 0
< X-Account-Container-Count: 1
< Accept-Ranges: bytes
< Content-Length: 14
< Content-Type: text/plain; charset=utf-8
< X-Trans-Id: tx3a125202e0854b1ca10e6c4dd74bf3e8
< Date: Tue, 08 Jan 2013 18:10:08 GMT
<
troycontainer
* Connection #0 to host hcs.hwcdn.net left intact
* Closing connection #0
Container Creation
- Let's create another container called
thisisacontainer
.-[~:$]- curl -v -X PUT -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > PUT /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 201 Created < Content-Length: 18 < Content-Type: text/html; charset=UTF-8 < X-Trans-Id: txbb649257e0a143ae878dcb565aefdcdc < Date: Tue, 08 Jan 2013 18:12:42 GMT < 201 Created * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
- Now let's list the containers again.
-[~:$]- curl -v -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > GET /v1/AUTH_sandboxaccount HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 200 OK < X-Account-Object-Count: 0 < X-Timestamp: 1357668566.86607 < X-Account-Bytes-Used: 0 < X-Account-Container-Count: 2 < Accept-Ranges: bytes < Content-Length: 31 < Content-Type: text/plain; charset=utf-8 < X-Trans-Id: tx32a202e793734de59c3db4c554598dd6 < Date: Tue, 08 Jan 2013 19:31:39 GMT < thisisacontainer troycontainer * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
Object Creation
- Let's place a file into
thisisacontainer
-[~:$]- curl -v -T /etc/resolv.conf -X PUT -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer/ * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > PUT /v1/AUTH_sandboxaccount/thisisacontainer/resolv.conf HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > Content-Length: 187 > Expect: 100-continue > * Done waiting for 100-continue * We are completely uploaded and fine < HTTP/1.1 201 Created < Content-Length: 118 < Content-Type: text/html; charset=UTF-8 < Etag: dd3a8ae2efc52bd19af8b818b3be220a < Last-Modified: Tue, 08 Jan 2013 19:33:12 GMT < X-Trans-Id: tx6c4251ded2ae471a8163b9628a3e0e7d < Date: Tue, 08 Jan 2013 19:33:12 GMT <html> <head> <title>201 Created</title> </head> <body> <h1>201 Created</h1> <br /><br /> </body> * Connection #0 to host hcs.hwcdn.net left intact </html> * Closing connection #0
- Now let's list the container again to ensure the file was ingested properly.
-[~:$]- curl -v -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > GET /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 200 OK < X-Container-Object-Count: 1 < X-Timestamp: 1357668761.98299 < X-Container-Bytes-Used: 187 < Accept-Ranges: bytes < Content-Length: 12 < Content-Type: text/plain; charset=utf-8 < X-Trans-Id: tx467e7b9a0bb94f4cbbed52885f82d4de < Date: Tue, 08 Jan 2013 19:34:06 GMT < resolv.conf * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
- List the account again.
Note: the Account bytes and Container counts. Also, these numbers are not quite real-time. They are rolled up constantly, though, so should only be minutes old.-[~:$]- curl -v -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > GET /v1/AUTH_sandboxaccount HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 200 OK < X-Account-Object-Count: 1 < X-Timestamp: 1357668566.86607 < X-Account-Bytes-Used: 187 < X-Account-Container-Count: 2 < Accept-Ranges: bytes < Content-Length: 31 < Content-Type: text/plain; charset=utf-8 < X-Trans-Id: txf17e3b6db62249e7b7408fd1c2628926 < Date: Tue, 08 Jan 2013 19:34:43 GMT < thisisacontainer troycontainer * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
Object Retrieval
- Download (display) the file we uploaded.
-[~:$]- curl -v -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer/resolv.conf * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > GET /v1/AUTH_sandboxaccount/thisisacontainer/resolv.conf HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 200 OK < Last-Modified: Tue, 08 Jan 2013 19:33:12 GMT < Etag: dd3a8ae2efc52bd19af8b818b3be220a < X-Timestamp: 1357673592.64506 < Accept-Ranges: bytes < Content-Length: 187 < Content-Type: text/plain < X-Trans-Id: tx414c7df2e5b0479cbfcd63e0ea134ecb < Date: Tue, 08 Jan 2013 19:41:12 GMT < * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
- You can also HEAD the file to get its metadata. Notice we're adding the Connection: close header just for convenience, otherwise the connection would have stayed open for a while and we would have had to Ctrl+C out of curl to get back to the command line.
-[~:$]- curl -v -X HEAD -H 'Connection: close' -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer/resolv.conf * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > HEAD /v1/AUTH_sandboxaccount/thisisacontainer/resolv.conf HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > Connection: close > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 200 OK < Last-Modified: Tue, 08 Jan 2013 19:33:12 GMT < Etag: dd3a8ae2efc52bd19af8b818b3be220a < X-Timestamp: 1357673592.64506 < Accept-Ranges: bytes < Content-Length: 108 < Content-Type: text/html < X-Trans-Id: tx11f30a350fea4ed68587bfc6a0e0b134 < Date: Tue, 08 Jan 2013 19:42:21 GMT < Connection: close < * transfer closed with 108 bytes remaining to read * Closing connection #0 curl: (18) transfer closed with 108 bytes remaining to read
Container/Object Deletion
- Let's try to delete the container. It will fail.
-[~:$]- curl -v -X DELETE -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > DELETE /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 409 Conflict < Content-Length: 77 < Content-Type: text/html; charset=UTF-8 < X-Trans-Id: tx6bbbab82d6314e09868f231dfd0bd940 < Date: Tue, 08 Jan 2013 19:55:46 GMT < 409 Conflict There was a conflict when trying to complete your request. * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
- This failed because it still contains objects. We have to delete all of the objects first.
-[~:$]- curl -v -X DELETE -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer/resolv.conf * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > DELETE /v1/AUTH_sandboxaccount/thisisacontainer/resolv.conf HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 204 No Content < Content-Length: 0 < Content-Type: text/html; charset=UTF-8 < X-Trans-Id: txa82f60c816cf4a24b2d51990efa07712 < Date: Tue, 08 Jan 2013 19:56:33 GMT < * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0 -[~:$]- curl -v -X DELETE -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > DELETE /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 204 No Content < Content-Length: 0 < Content-Type: text/html; charset=UTF-8 < X-Trans-Id: tx0a7e1ba480a84454a2ddd61cb365dfb0 < Date: Tue, 08 Jan 2013 19:56:47 GMT < * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
Permissions
- Now, let's create a container again.
-[~:$]- curl -v -X PUT -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer* About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > PUT /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 201 Created < Content-Length: 18 < Content-Type: text/html; charset=UTF-8 < X-Trans-Id: tx061049cf25dd464ca7986a9f940dbe43 < Date: Tue, 08 Jan 2013 20:22:45 GMT < 201 Created
- We've set up another user in the
sandboxaccount
customer calledsandboxuser2
. This user is NOT an admin. Let's see what we can do with it.-[~:$]- curl -v -H 'X-Storage-User: sandboxaccount:sandboxuser2' -H 'X-Storage-Pass: sandboxpa55wd2' http://hcs.hwcdn.net/auth/v1.0* About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > GET /auth/v1.0 HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Storage-User: sandboxaccount:sandboxuser2 > X-Storage-Pass: sandboxpa55wd2 > < HTTP/1.1 200 OK < X-Storage-Url: http://hcs.hwcdn.net/v1/AUTH_sandboxaccount < X-Storage-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910 < X-Auth-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910 < X-Trans-Id: txbe06ac0a4ba94220a6f61a40e17eed68 < Content-Length: 0 < Date: Tue, 08 Jan 2013 20:24:33 GMT < * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0 -[~:$]- curl -v -H 'X-Auth-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > GET /v1/AUTH_sandboxaccount HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910 > < HTTP/1.1 403 Forbidden < Content-Length: 157 < Content-Type: text/html; charset=UTF-8 < X-Trans-Id: tx7fd24ca4b35142d8abdef208e8a98894 < Date: Tue, 08 Jan 2013 20:25:07 GMT < <html> <head> <title>403 Forbidden</title> </head> <body> <h1>403 Forbidden</h1> Access was denied to this resource.<br /><br /> </body> * Connection #0 to host hcs.hwcdn.net left intact </html>* Closing connection #0
- We can't list containers as a non-admin account. That's normal, and we can't change that. But we know the
thisisacontainer
container exists. So let's try to read that.-[~:$]- curl -v -H 'X-Auth-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > GET /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910 > < HTTP/1.1 403 Forbidden < Content-Length: 157 < Content-Type: text/html; charset=UTF-8 < X-Trans-Id: tx3222f68bf89f459a9afa14c4dee08e7d < Date: Tue, 08 Jan 2013 20:38:31 GMT < <html> <head> <title>403 Forbidden</title> </head> <body> <h1>403 Forbidden</h1> Access was denied to this resource.<br /><br /> </body> * Connection #0 to host hcs.hwcdn.net left intact </html>* Closing connection #0
- Just what we expected. So let's fix that. Let's give everyone in
sandboxaccount
read access using our other user's admin capabilities. Note that we're switching back to the other user'sX-Auth-Token
.-[~:$]- curl -v -X PUT -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' -H 'X-Container-Read: sandboxaccount' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > PUT /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > X-Container-Read: sandboxaccount > < HTTP/1.1 202 Accepted < Content-Length: 58 < Content-Type: text/html; charset=UTF-8 < X-Trans-Id: tx55f1f0dae1634852a81769afc6d9491d < Date: Tue, 08 Jan 2013 20:43:43 GMT < 202 Accepted The request is accepted for processing. * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
- And let's try reading again with
sandboxuser2
's token.-[~:$]- curl -v -H 'X-Auth-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer* About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > GET /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910 > < HTTP/1.1 204 No Content < X-Container-Object-Count: 0 < X-Timestamp: 1357668761.98299 < X-Container-Bytes-Used: 0 < Accept-Ranges: bytes < Content-Length: 0 < X-Trans-Id: txa577f043b3f5414698b6e64336335403 < Date: Tue, 08 Jan 2013 20:44:04 GMT < * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
- There is a subtle difference in the headers when an admin account lists the container, so let's see that.
Note: theX-Container-Read
in the response headers.-[~:$]- curl -v -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer* About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > GET /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 204 No Content < X-Container-Object-Count: 0 < X-Timestamp: 1357668761.98299 < X-Container-Read: sandboxaccount < X-Container-Bytes-Used: 0 < Accept-Ranges: bytes < Content-Length: 0 < X-Trans-Id: txb92d6573816445468a1052d004d65ee6 < Date: Tue, 08 Jan 2013 20:45:39 GMT < * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
- Let's try a write with
sandboxuser2
's token. We expect it to fail since we haven't given that permission.-[~:$]- curl -v -X PUT -T /etc/resolv.conf -H 'X-Auth-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer/resolv.conf * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > PUT /v1/AUTH_sandboxaccount/thisisacontainer/resolv.conf HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910 > Content-Length: 187 > Expect: 100-continue > * Done waiting for 100-continue * We are completely uploaded and fine < HTTP/1.1 403 Forbidden < Content-Length: 157 < Content-Type: text/html; charset=UTF-8 < X-Trans-Id: tx7b0f7f9c1fc54e0da556d01ed2dfaec7 < Date: Tue, 08 Jan 2013 20:50:49 GMT <html> <head> <title>403 Forbidden</title> </head> <body> <h1>403 Forbidden</h1> Access was denied to this resource.<br /><br /> </body> * Connection #0 to host hcs.hwcdn.net left intact </html>* Closing connection #0
- Ok, now let's give only
sandboxuser2
write access (instead of the whole customer)-[~:$]- curl -v -X PUT -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' -H 'X-Container-Write: sandboxaccount:sandboxuser2' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > PUT /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > X-Container-Write: sandboxaccount:sandboxuser2 > < HTTP/1.1 202 Accepted < Content-Length: 58 < Content-Type: text/html; charset=UTF-8 < X-Trans-Id: txbebadf4716a245f390756a19948a25ca < Date: Tue, 08 Jan 2013 20:51:18 GMT < 202 Accepted The request is accepted for processing. * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
- And now we can upload with
sandboxuser2
's token.-[~:$]- curl -v -X PUT -T /etc/resolv.conf -H 'X-Auth-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer/resolv.conf * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > PUT /v1/AUTH_sandboxaccount/thisisacontainer/resolv.conf HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tkdd95e58aba004263b38bd502bf5ee910 > Content-Length: 187 > Expect: 100-continue > * Done waiting for 100-continue * We are completely uploaded and fine < HTTP/1.1 201 Created < Content-Length: 118 < Content-Type: text/html; charset=UTF-8 < Etag: dd3a8ae2efc52bd19af8b818b3be220a < Last-Modified: Tue, 08 Jan 2013 20:53:14 GMT < X-Trans-Id: tx76a16fb24d8b48ef83b4bc2ab351b522 < Date: Tue, 08 Jan 2013 20:53:14 GMT < <html> <head> <title>201 Created</title> </head> <body> <h1>201 Created</h1> <br /><br /> </body> * Connection #0 to host hcs.hwcdn.net left intact </html>* Closing connection #0
- Let's read the container with the admin account again.
-[~:$]- curl -v -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer* About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > GET /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 200 OK < X-Container-Object-Count: 1 < X-Container-Write: sandboxaccount:sandboxuser2 < X-Timestamp: 1357668761.98299 < X-Container-Read: sandboxaccount < X-Container-Bytes-Used: 187 < Accept-Ranges: bytes < Content-Length: 12 < Content-Type: text/plain; charset=utf-8 < X-Trans-Id: tx05c0ab02320446c8935dafc18a6fafab < Date: Tue, 08 Jan 2013 20:54:14 GMT < resolv.conf * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
- We see both of the ACL headers. Now let's alter the read ACL.
-[~:$]- curl -v -X PUT -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' -H 'X-Container-Read: sandboxaccount:sandboxuser2' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer * About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > PUT /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > X-Container-Read: sandboxaccount:sandboxuser2 > < HTTP/1.1 202 Accepted < Content-Length: 58 < Content-Type: text/html; charset=UTF-8 < X-Trans-Id: tx547d371c03bd4a8287133d4784c0d8b3 < Date: Tue, 08 Jan 2013 20:55:53 GMT < 202 Accepted The request is accepted for processing. * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0
- Now let's view the ACLs on that container again. Notice that we replaced the read ACL.
-[~:$]- curl -v -H 'X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3' http://hcs.hwcdn.net/v1/AUTH_sandboxaccount/thisisacontainer* About to connect() to hcs.hwcdn.net port 80 (#0) * Trying 69.16.168.135... * connected * Connected to hcs.hwcdn.net (69.16.168.135) port 80 (#0) > GET /v1/AUTH_sandboxaccount/thisisacontainer HTTP/1.1 > User-Agent: curl/7.26.0 > Host: hcs.hwcdn.net > Accept: */* > X-Auth-Token: AUTH_tk94bcb8779f954a64bed03ab74e617ba3 > < HTTP/1.1 200 OK < X-Container-Object-Count: 1 < X-Container-Write: sandboxaccount:sandboxuser2 < X-Timestamp: 1357668761.98299 < X-Container-Read: sandboxaccount:sandboxuser2 < X-Container-Bytes-Used: 187 < Accept-Ranges: bytes < Content-Length: 12 < Content-Type: text/plain; charset=utf-8 < X-Trans-Id: txf73829607137469e947a2c5ac17c7cc3 < Date: Tue, 08 Jan 2013 20:56:05 GMT < resolv.conf * Connection #0 to host hcs.hwcdn.net left intact * Closing connection #0