Rackspace Cloud Files
Rackspace Cloud Files
Rackspace Cloud Files
com/api
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
RACKSPACE MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, AS TO THE ACCURACY OR
COMPLETENESS OF THE CONTENTS OF THIS DOCUMENT AND RESERVES THE RIGHT TO MAKE CHANGES TO SPECIFICATIONS AND
PRODUCT/SERVICES DESCRIPTION AT ANY TIME WITHOUT NOTICE. RACKSPACE SERVICES OFFERINGS ARE SUBJECT TO CHANGE
WITHOUT NOTICE. USERS MUST TAKE FULL RESPONSIBILITY FOR APPLICATION OF ANY SERVICES MENTIONED HEREIN. EXCEPT
AS SET FORTH IN RACKSPACE GENERAL TERMS AND CONDITIONS AND/OR CLOUD TERMS OF SERVICE, RACKSPACE ASSUMES NO
LIABILITY WHATSOEVER, AND DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO ITS SERVICES INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
Except as expressly provided in any written license agreement from Rackspace, the furnishing of this document does not give you any
license to patents, trademarks, copyrights, or other intellectual property.
Rackspace®, Rackspace logo and Fanatical Support® are registered service marks of Rackspace US, Inc. All other product names and
trademarks used in this document are for identification purposes only and are property of their respective owners.
ii
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Table of Contents
1. Overview ..................................................................................................................... 1
1.1. Intended Audience ........................................................................................... 1
1.2. Document Change History ................................................................................ 2
1.3. Additional Resources ........................................................................................ 4
1.4. Pricing and Service Level ................................................................................... 5
2. Concepts ..................................................................................................................... 6
2.1. Accounts .......................................................................................................... 6
2.2. Authentication ................................................................................................. 6
2.3. Permissions ....................................................................................................... 6
2.4. Containers ........................................................................................................ 6
2.5. Objects ............................................................................................................. 7
2.6. Operations ....................................................................................................... 7
2.7. CDN-enabled Containers ................................................................................... 8
2.8. Language-Specific APIs ..................................................................................... 9
3. General API Information ........................................................................................... 10
3.1. Authentication ............................................................................................... 10
3.1.1. Geographic Endpoints .......................................................................... 10
3.1.2. Retrieving the Authentication Token .................................................... 10
3.2. Role Based Access Control .............................................................................. 19
3.2.1. Assigning Roles to Account Users ......................................................... 19
3.2.2. Roles Available for Cloud Files .............................................................. 19
3.2.3. Resolving Conflicts Between RBAC Multiproduct vs. Custom (Product-
specific) Roles ................................................................................................ 20
3.2.4. RBAC Permissions Cross-reference to Cloud Files API Operations ............ 20
3.3. Service Access Endpoints ................................................................................. 20
3.4. Cloud Files Service Contract Version ................................................................ 22
3.5. Absolute Limits ............................................................................................... 23
3.6. Request and Response Types .......................................................................... 23
4. Overview of API Operations ...................................................................................... 24
5. API Operations for Storage Services ........................................................................... 26
5.1. Account Services ............................................................................................. 27
5.1.1. List Account Containers ....................................................................... 28
5.1.2. Create or Update Account Metadata ................................................... 32
5.1.3. Get Account Metadata ........................................................................ 34
5.1.4. Delete Account Metadata .................................................................... 36
5.2. Container Services .......................................................................................... 36
5.2.1. List Container Objects .......................................................................... 38
5.2.2. Create Container ................................................................................. 42
5.2.3. Delete Container .................................................................................. 44
5.2.4. Create or Update Container Metadata ................................................. 45
5.2.5. Get Container Metadata ...................................................................... 47
5.2.6. Delete Container Metadata .................................................................. 49
5.3. Object Services ............................................................................................... 50
5.3.1. Get Object Data .................................................................................. 51
5.3.2. Create or Update Object ...................................................................... 54
5.3.3. Delete Object ...................................................................................... 57
5.3.4. Copy Object ......................................................................................... 59
5.3.5. Get Object Metadata ........................................................................... 62
iii
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
iv
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
v
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
List of Figures
4.1. Cloud Files System Interfaces .................................................................................. 25
vi
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
List of Tables
3.1. Cloud Files Product Roles and Permissions ............................................................... 19
3.2. Multiproduct (Global) Roles and Permissions ........................................................... 20
3.3. Regionalized Service Endpoints for Storage Services ................................................ 20
3.4. Regionalized Service Endpoints for CDN Management Services ................................ 22
3.5. Absolute Limits ....................................................................................................... 23
5.1. Cloud Files Supported Range Formats ..................................................................... 51
7.1. Metadata Values for Setting Container Quotas ....................................................... 68
8.1. Comparison of Static and Dynamic Large Objects .................................................... 72
13.1. Supported CORS Container Headers .................................................................... 113
vii
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
List of Examples
3.1. Auth Request: XML ................................................................................................ 10
3.2. Auth Request: JSON ............................................................................................... 11
3.3. Auth Response: XML .............................................................................................. 12
3.4. Auth Response: JSON ............................................................................................. 14
3.5. Example Request URL (contract version in bold) ..................................................... 22
5.1. List Account Containers Request: XML .................................................................... 30
5.2. List Account Containers Request: JSON ................................................................... 30
5.3. List Account Containers Response: XML .................................................................. 31
5.4. List Account Containers Response: JSON ................................................................. 31
5.5. Create or Update Account Metadata Request ......................................................... 32
5.6. Create or Update Account Metadata Response ....................................................... 32
5.7. Get Account Metadata Request .............................................................................. 34
5.8. Get Account Metadata Response ............................................................................ 34
5.9. Delete Account Metadata Request ......................................................................... 36
5.10. Delete Account Metadata Response ..................................................................... 36
5.11. List Container Objects Request .............................................................................. 40
5.12. List Container Objects Request: XML ..................................................................... 40
5.13. List Container Objects Request: JSON .................................................................... 40
5.14. List Container Objects Response ............................................................................ 40
5.15. List Container Objects Response: XML ................................................................... 41
5.16. List Container Objects Response: JSON .................................................................. 41
5.17. Create Container Request ..................................................................................... 42
5.18. Create Container with Metadata Request ............................................................. 43
5.19. Create Container Response ................................................................................... 43
5.20. Create Container with Metadata Response ........................................................... 43
5.21. Delete Container Request ..................................................................................... 44
5.22. Delete Container Response ................................................................................... 44
5.23. Create or Update Container Metadata Request ..................................................... 45
5.24. Create or Update Container Metadata Response ................................................... 46
5.25. Get Container Metadata Request .......................................................................... 47
5.26. Get Container Metadata Response ....................................................................... 48
5.27. Delete Container Metadata Request ..................................................................... 49
5.28. Delete Container Metadata Response ................................................................... 49
5.29. Get Object Data Request ...................................................................................... 52
5.30. Get Object Data Request Using Range .................................................................. 52
5.31. Get Object Data Request Using Multiple Ranges ................................................... 52
5.32. Get Object Data Response .................................................................................... 52
5.33. Get Object Data Response Using Range ................................................................ 52
5.34. Get Object Data Response Using Multiple Ranges ................................................. 53
5.35. Create or Update Object Request ......................................................................... 55
5.36. Create or Update Object Response ....................................................................... 56
5.37. Delete Object Request .......................................................................................... 57
5.38. Delete Object Response ........................................................................................ 57
5.39. Copy Object Method 1 - Using PUT ....................................................................... 59
5.40. Copy Object Method 2 - Using COPY .................................................................... 59
5.41. Data Center Endpoints ......................................................................................... 60
5.42. Copy Object Request Using PUT ............................................................................ 61
5.43. Copy Object Request Using COPY ......................................................................... 61
viii
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
ix
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
x
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
1. Overview
Rackspace Cloud Files™ is an affordable, redundant, scalable, and dynamic storage service
offering. The core storage system is designed to provide a secure, network-accessible way
to store an unlimited number of files. Each file can be as large as 5 gigabytes. You can store
as much as you want and pay only for storage space that you actually use.
Additionally, Cloud Files provides a simple yet powerful way to publish and distribute
content behind a Content Distribution Network. As a Cloud Files user, you get access to
this network automatically without having to worry about contracts, additional costs, or
technical hurdles.
Cloud Files allows you to store and retrieve files and CDN-enabled content through a simple
Web Services interface (REST: Representational State Transfer). There are also language-
specific APIs that utilize the RESTful API but make it much easier for developers to integrate
into their applications.
For more details on the Cloud Files service, please refer to http://www.rackspace.com/
cloud/files/ and to the Knowledge Center article Best Practices for Using Cloud Files.
1.1. Intended Audience
This guide is intended to assist software developers who want to develop applications
using the Rackspace Cloud Files API. It fully documents the REST application programming
interface (API) that allows developers to interact with the storage and CDN components
of the Cloud Files system. To use the information provided here, you should first have a
general understanding of the Rackspace Cloud Files service and have access to an active
Rackspace Cloud Files account. You should also be familiar with:
System administrators and others interested in the storage and CDN benefits of Cloud Files
should consider using the File Manager interface within the Rackspace Cloud Control Panel,
Jungle Disk, or third party tools such as Fileuploader or Cyberduck. The Rackspace Cloud
Control Panel provides an easy to use web-based interface for uploading and downloading
content to and from Cloud Files.
1
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
If you set this header to True, the Content-Type that is sent in the request (if any) is
ignored, and Content-Type is guessed by using the Python mimetypes library based on
the object path.
• Reworked Chapter 5, “API Operations for Storage Services” [26] and Chapter 9, “API
Operations for CDN Services” [82] by using Web Application Description Language
(WADL) files for the resource and method descriptions.
December 31, 2013 • Updated the instructions for locating the API Key in the Cloud Control Panel in Section 3.1.2,
“Retrieving the Authentication Token” [10].
• Added a table of all API operations, which lists and briefly describes all API operations. Also
added tables showing the API operations at the beginning of each section that describes the
operations.
• Added service access endpoints for the CDN management service component to Section 3.3,
“Service Access Endpoints” [20].
• In all examples, updated the X-Auth-Token to use the current format returned by an
authentication request (no dashes). Also updated examples to use real values for account,
container, and object.
November 26, 2013 • Added Section 8.2, “Create Large Objects” [70] with more information about Dynamic
Large Objects and Static Large Objects.
• Updated Section 12.2, “Extract Archive” [102] to include a note about using a blank
Content-Type to have Cloud Files determine the file type for the archive.
November 22, 2013 • Added service catalog information for cloudfilesCDN endpoints (Section 3.3, “Service
Access Endpoints” [20]).
• Made miscellaneous updates throughout this book to improve wording and consistency.
November 1, 2013 • Replaced references to X-Storage-Url and X-Cdn-Management–Url throughout this
document with references to the cloudFiles and cloudFilesCDN endpoints in the
service catalog based on use of Identity v2.0 rather than Identity v1.0.
2
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
• Updated Section 13.2.2, “Create the Form” [110] to indicate that the value of redirect
(see Example 7.9) can be empty to indicate that no redirect is included on the form.
September 26, 2013 • Added Section 3.2, “Role Based Access Control” [19].
• In Section 14.2, “Authentication with cURL” [116], updated the example to show v2.0 for
authentication.
3
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
1.3. Additional Resources
You can download the most current version of this document from the Rackspace Cloud
website at docs.rackspacecloud.com/files/api/cf-devguide-latest.pdf.
For more details about the Cloud Files service, please refer to http://www.rackspace.com/
cloud/files/. Related documents are available at the same site, as are links to official
Rackspace support channels, including Knowledge Center articles, forums, phone, chat, and
email.
For information about the Rackspace language-specific APIs that you can use for Cloud
Files, refer to Rackspace Cloud SDKs Software Development Kit Guide. Each language-
specific API includes its own documentation (either HTML, PDF, or CHM) including code
snippets and examples to help you get started. For information in this book about the
language-specific APIs, refer to Language-Specific API Bindings.
4
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
The Service Level Agreement (SLA) for Cloud Files is available at http://
www.rackspace.com/information/legal/cloud/sla#files.
5
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
2. Concepts
Cloud Files is not a file system in the traditional sense. You will not be able to map or
mount virtual disk drives like you can with other forms of storage such as a SAN or NAS.
Since Cloud Files is a different way of thinking when it comes to storage, you should take a
few moments to review the key concepts listed below.
2.1. Accounts
The Cloud Files system is designed to be used by many different customers. Your user
account is your portion of the Cloud Files system. You must identify yourself with
your Rackspace Cloud user name and API access key and once authenticated, you
have full read/write access to the files stored under your account. Please visit http://
www.rackspacecloud.com/signup to obtain a Cloud Files account and enable your API
access key.
2.2. Authentication
Section 3.1, “Authentication” [10] describes how to authenticate against the Rackspace
Cloud Identity service to receive Cloud Files connection parameters and an authentication
token. The token must be passed in for Cloud Files operations during the time it is valid.
For more information about authentication, see the Cloud Identity Client Developer Guide,
v2.0 at docs.rackspace.com.
Note
The language-specific APIs handle authentication, token passing, and HTTPS
request/response communication.
2.3. Permissions
In Cloud Files, you have your own storage account and has full access to that
account. You must authenticate with your credentials as described in Section 3.1,
“Authentication” [10], but once authenticated you can perform all Cloud Files
operations within that account.
2.4. Containers
A container is a storage compartment that provides a way for you to organize your data.
You can think of a container as a folder in Windows® or a directory in UNIX®. The primary
difference between a container and these other file system concepts is that containers
cannot be nested. You can have up to 500,000 containers in your account. Data must be
stored in a container so you must have at least one container defined in your account prior
to uploading data.
If you expect to write more than 100 objects per second to a single container, we
recommend organizing those objects across multiple containers to improve performance.
6
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
The only restrictions on container names is that they cannot contain a forward slash (/) and
must be less than 256 bytes in length. Note that the length restriction applies to the name
after it has been URL-encoded. For example, a container name of Course Docs would be
URL-encoded as Course%20Docs and is 13 bytes in length rather than the expected 11.
You can create a container in any Rackspace data center. (See Section 3.3, “Service Access
Endpoints” [20] for a list.) However, in order to lower your costs, you should create
your most served containers in the same data center as your server. Otherwise, you will
be billed for external bandwidth charges. Note that this is true when computations are
performed on objects but is not true for static content served to end users directly.
2.5. Objects
Objects are the basic storage entities in Cloud Files. They represent the files and their
optional metadata you upload to the system. When you upload objects to Cloud Files,
the data is stored as-is (without compression or encryption) and consists of a location
(container), the object's name, and any metadata you assign consisting of key/value pairs.
For instance, you can choose to store a backup of your digital photos and organize them
into albums. In this case, each object could be tagged with metadata such as Album :
Caribbean Cruise or Album : Aspen Ski Trip.
The only restriction on object names is that they must be less than 1024 bytes in length
after URL-encoding. For example, an object name of C++final(v2).txt should be URL-
encoded as C%2B%2Bfinal%28v2%29.txt and therefore be 24 bytes in length rather
than the expected 16.
Cloud Files has a limit on the size of a single uploaded object. By default this limit is 5 GB.
However, the download size of a single object is virtually unlimited with the concept of
segmentation. Segments of the larger object are uploaded and a special manifest file is
created that, when downloaded, sends all the segments concatenated as a single object.
This also offers much greater upload speed with the possibility of parallel uploads of the
segments.
For metadata, you should not exceed 90 individual key/value pairs for any one object and
the total byte length of all key/value pairs should not exceed 4KB (4096 bytes).
2.6. Operations
Operations are the actions you perform within your account, such as creating or deleting
containers or uploading or downloading objects. The full list of operations is given in
Chapter 5, “API Operations for Storage Services” [26]. The operations are then
described in the following REST API sections;
Operations may be performed through the REST web service API or a language-specific AP.
(For information about the Rackspace language-specific APIs, see Rackspace Cloud SDKs
Software Development Kit Guide.)
7
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Important
All operations must include a valid authorization token.
2.7. CDN-enabled Containers
CDN-enabled containers serve content through Akamai's content delivery network (CDN).
CDN-enabled containers are publicly accessible for read access, so they do not require an
authorization token for read access. However, uploading content into a CDN-enabled
container is a secure operation and requires a valid authentication token.
Each CDN-enabled container has a unique URL that can be combined with its object names
and openly distributed in web pages, emails, or other applications.
This URL can be embedded in items like HTML pages, email messages, or blog posts.
The first time that URL is accessed, a copy of that image is fetched from the Cloud Files
storage system. The copy is cached in a CDN and served from there for all subsequent
requests for a configurable cache time to live (TTL) value. Setting the TTL of a CDN-enabled
container translates to setting the Expires and Cache-Control HTTP headers. Note
that extremely long TTL values do not guarantee that an object is served from a CDN edge
location. When the TTL expires, the CDN checks Cloud Files to ensure that it has the most
up-to-date content. A purge request forces the CDN to check with Cloud Files for the most
up-to-date version of the file.
Cloud Files continues to serve content through the CDN until it receives a delete request.
Note
For more information about TTL, including its default, minimum, and maximum
values, see Section 9.3, “CDN Object Services” [93].
Containers tracked in the CDN management service are completely separate and distinct
from the containers defined in the storage service. It is possible for a container to be CDN-
enabled even if it does not exist in the storage system. You might want the ability to pre-
generate CDN URLs before actually uploading content and this separation gives you that
ability.
However, for the content to be served from the CDN, the container names MUST match in
both the CDN management service and the storage service. For example, you could CDN-
enable a container called images and be assigned the CDN URL, but you also need to
create a container called images in the storage service.
8
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
2.8. Language-Specific APIs
Language-specific APIs in several popular languages are available to help put Cloud Files in
the hands of developers. These language-specific APIs provide a layer of abstraction on top
of the base REST API, allowing programmers to work with a container and object model
instead of working directly with HTTP requests and responses. The language-specific APIs
are free to download, use, and modify. They are licensed under the MIT license as described
in the COPYING file packaged with each API. If you make any improvements to an API, you
are encouraged (but not required) to submit those changes back to Rackspace.
Detailed information about the language-specific APIs is in the Rackspace Cloud SDKs
Software Development Kit Guide. If you have changes that you would like to see in the
Cloud File language-specific APIs, email them to [email protected]. Make sure to
indicate which language and version you modified and send a unified diff.
Each language-specific API has its own documentation (in HTML, PDF, or CHM format)
including code snippets and examples to help you get started.
You are welcome to create your own language-specific APIs. Rackspace will help answer
any questions during development, host your code if you like, and give you full credit for
your work.
9
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
3.1. Authentication
Every REST request against the Cloud Files service requires the inclusion of a specific
authorization token, supplied by the X-Auth-Token HTTP header. Customers obtain this
token by first using the Rackspace Cloud Authentication Service and supplying a valid user
name and API access key.
3.1.1. Geographic Endpoints
The Rackspace Cloud Authentication Service serves as the entry point to all Rackspace
Cloud APIs and is itself a RESTful web service.
You can use either of the following endpoints to access the Authentication Service,
regardless of US or UK identities:
• https://identity.api.rackspacecloud.com/v2.0/.
• https://lon.identity.api.rackspacecloud.com/v2.0/.
Your account may be based in either the US or the UK. This is not determined by your
physical location but by the location of the Rackspace retail site that was used to create
your account.
If you are unsure how your account was created, use the Rackspace contact information at
either site to ask for help.
Error Status Code(s): unauthorized (401), userDisabled (403), badRequest (400), authFault
(500), serviceUnavailable (503)
The authenticate operation provides clients with an authentication token and a list of
regional cloud endpoints. The sample requests and responses in this section illustrate
a general case. In your authentication request, use your own credentials rather than
the sample values shown here for username and apiKey. When you authenticate
successfully, the response to your authentication request will include a catalog of the
services to which you have subscribed rather than the sample values shown here.
10
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
{
"auth":
{
"RAX-KSKEY:apiKeyCredentials":
{
"username": "jsmith",
"apiKey": "aaaaa-bbbbb-ccccc-12345678"
}
}
}
2. On the upper-right side of the top navigation pane, click your username.
4. In the Login Details section of the Account Settings page, locate the API Key field
and click Show.
5. Copy the value of the API Key and paste it into a text editor of your choice.
11
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
You also need your cloud account number. In the documentation, the account
number is often referred to as your tenant name or tenant ID (technically, the ID is
different from the name, but at Rackspace, they are the same thing). Together, three
components—your username, your API Key, and your tenant ID or cloud account
number—form the authentication credentials that are required to connect to the
Rackspace cloud.
To find your tenant ID or cloud account number, locate your username on the upper-
right side of the top navigation pane in the Cloud Control Panel. The tenant ID or
account number is in parentheses just to the right of your username.
Note
For Cloud Files, the information used in place of the account number with
the API operations is the MossoCloudFS_aaaaaaaa-bbbb-cccc-
dddd-eeeeeeeeeeee information found in service catalog of your
authentication response, rather than the account number found in the
Cloud Control Panel, as described above.
12
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
</service>
<service type="rax:load-balancer" name="cloudLoadBalancers">
<endpoint region="DFW" tenantId="1100111" publicURL="https://dfw.
loadbalancers.api.rackspacecloud.com/v1.0/1100111"/>
<endpoint region="ORD" tenantId="1100111" publicURL="https://ord.
loadbalancers.api.rackspacecloud.com/v1.0/1100111"/>
</service>
<service type="compute" name="cloudServersOpenStack">
<endpoint region="DFW" tenantId="1100111"
publicURL="https://dfw.servers.api.rackspacecloud.com/v2/1100111">
<version id="2" info="https://dfw.servers.api.rackspacecloud.com/v2/"
list="https://dfw.servers.api.rackspacecloud.com/" />
</endpoint>
<endpoint region="ORD" tenantId="1100111"
publicURL="https://ord.servers.api.rackspacecloud.com/v2/1100111">
<version id="2" info="https://ord.servers.api.rackspacecloud.com/v2/"
list="https://ord.servers.api.rackspacecloud.com/" />
</endpoint>
</service>
<service type="compute" name="cloudServers">
<endpoint tenantId="1100111"
publicURL="https://servers.api.rackspacecloud.com/v1.0/1100111">
<version id="1.0"
info="https://servers.api.rackspacecloud.com/v1.0/"
list="https://servers.api.rackspacecloud.com/"/>
</endpoint>
</service>
<service type="object-store" name="cloudFiles">
<endpoint region="DFW"
tenantId="MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeee eee"
publicURL="https://storage101.dfw1.clouddrive.com/v1/
MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
internalURL="https://snet-storage101.dfw1.clouddrive.com/v1/
MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"/>
<endpoint region="ORD"
tenantId="MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
publicURL="https://storage101.ord1.clouddrive.com/v1/
MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
internalURL="https://snet-storage101.ord1.clouddrive.com/v1/
MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"/>
</service>
<service type="rax:object-cdn" name="cloudFilesCDN">
<endpoint region="DFW"
tenantId="MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
publicURL="https://cdn1.clouddrive.com/v1/MossoCloudFS_aaaaaaaa-bbbb-
cccc-dddd-eeeeeeeeeeee"/>
<endpoint region="ORD"
tenantId="MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
publicURL="https://cdn2.clouddrive.com/v1/MossoCloudFS_aaaaaaaa-bbbb-
cccc-dddd-eeeeeeeeeeee"/>
</service>
<service type="rax:dns" name="cloudDNS">
<endpoint tenantId="1100111"
publicURL="https://dns.api.rackspacecloud.com/v1.0/1100111"/>
</service>
</serviceCatalog>
</access>
13
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
{
"access": {
"token": {
"expires": "2011-12-08T22:51:02.000-06:00",
"id": "vvvvvvvv-wwww-xxxx-yyyy-zzzzzzzzzzzz"
},
"user": {
"id": "123456",
"name": "jsmith",
"RAX-AUTH:defaultRegion": "DFW",
"roles": [
{
"description": "Admin Role.",
"id": "identity:admin",
"name": "identity:admin"
},
{
"description": "Default Role.",
"id": "identity:default",
"name": "identity:default"
}
]
},
"serviceCatalog": [
{
"endpoints": [
{
"publicURL": "https://dfw.databases.api.
rackspacecloud.com/v1.0/1100111",
"region": "DFW",
"tenantId": "1100111"
},
{
"publicURL": "https://ord.databases.api.
rackspacecloud.com/v1.0/1100111",
"region": "ORD",
"tenantId": "1100111"
}
],
"name": "cloudDatabases",
"type": "rax:database"
},
{
"endpoints": [
{
"publicURL": "https://dfw.loadbalancers.api.
rackspacecloud.com/v1.0/1100111",
"region": "DFW",
"tenantId": "1100111"
},
{
14
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
"publicURL": "https://ord.loadbalancers.api.
rackspacecloud.com/v1.0/1100111",
"region": "ORD",
"tenantId": "1100111"
}
],
"name": "cloudLoadBalancers",
"type": "rax:load-balancer"
},
{
"endpoints": [
{
"tenantId": "1100111",
"region": "DFW",
"publicURL": "https://dfw.servers.api.rackspacecloud.
com/v2/1100111",
"versionId": "2",
"versionInfo": "https://dfw.servers.api.
rackspacecloud.com/v2/",
"versionList": "https://dfw.servers.api.
rackspacecloud.com/"
},
{
"tenantId": "1100111",
"region": "ORD",
"publicURL": "https://ord.servers.api.rackspacecloud.
com/v2/1100111",
"versionId": "2",
"versionInfo": "https://ord.servers.api.
rackspacecloud.com/v2/",
"versionList": "https://ord.servers.api.
rackspacecloud.com/"
}
],
"name": "cloudServersOpenStack",
"type": "compute"
},
{
"endpoints": [
{
"tenantId": "1100111",
"publicURL": "https://servers.api.rackspacecloud.com/
v1.0/1100111",
"versionId": "1.0",
"versionInfo": "https://servers.api.rackspacecloud.
com/v1.0/",
"versionList": "https://servers.api.rackspacecloud.
com/"
}
],
"name": "cloudServers",
"type": "compute"
},
{
"endpoints": [
{
"tenantId": "MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-
eeeeeeeeeeee",
"publicURL": "https://storage101.dfw1.clouddrive.com/
v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
15
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
"internalURL": "https://snet-storage101.dfw1.
clouddrive.com/v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"region": "DFW"
},
{
"tenantId": "MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-
eeeeeeeeeeee",
"publicURL": "https://storage101.ord1.clouddrive.com/
v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"internalURL": "https://snet-storage101.ord1.
clouddrive.com/v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"region": "ORD"
}
],
"name": "cloudFiles",
"type": "object-store"
},
{
"endpoints": [
{
"tenantId": "MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-
eeeeeeeeeeee",
"publicURL": "https://cdn1.clouddrive.com/v1/
MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"region": "DFW"
},
{
"tenantId": "MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-
eeeeeeeeeeee",
"publicURL": "https://cdn2.clouddrive.com/v1/
MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"region": "ORD"
}
],
"name": "cloudFilesCDN",
"type": "rax:object-cdn"
},
{
"endpoints": [
{
"tenantId": "1100111",
"publicURL": "https://dns.api.rackspacecloud.com/v1.0/
1100111"
}
],
"name": "cloudDNS",
"type": "rax:dns"
}
]
}
}
Note
The information shown in the Auth Response examples is for US-based
accounts. If you authenticate against the UK-endpoint for auth, you will see the
service catalog information for UK-based accounts.
16
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
In XML responses only, a list of namespaces identifies API extensions that add
functionality to the core API.
The token's expires attribute denotes the time after which the token will
automatically become invalid. A token may be manually revoked before the time
identified by the expires attribute. The expires attribute predicts a token's
maximum possible lifespan but does not guarantee that it will reach that lifespan.
Clients are encouraged to cache a token until it expires.
Users can be assigned a default region so that, when there is a choice between
multiple endpoints associated with a service in the user's catalog, the endpoint for the
user's default region will be selected if it is available. In this example, the user's default
region is DFW and several of the services in the catalog offer endpoints in that region
and the ORD region. The user's work will be directed to the DFW region whenever
possible.
Users can be assigned multiple roles, with each role providing specific privileges.
In this example, jsmith is the administrative user for the account, holding the
fully-privileged identity:admin role. Other users might hold other roles with
different privileges. Roles need not be associated with actual job functions such as
Administrator, Operator, Developer, Tester, or Trainer.
The service catalog lists the services you can access. In this example, the user can access
one database service, one loadbalancing service, two compute services (Cloud Servers
OpenStack and Cloud Servers), two object storage services (Cloud Files Content
Distribution Network (CDN), and Cloud Files), and one DNS service. The catalog
listing for each service provides at least one endpoint URL for that service. Other
information, such as regions, versions, and tenants, is provided if it's relevant to this
user's access to this service.
The service type attribute identifies services that perform similar functions, whatever
those services might be named. In this example, the services named cloudServers and
cloudServersOpenstack are both identified as type="compute", identifying them as
compute services even though the word "compute" does not appear in their names.
Important
Use service type as the primary value for locating a service. If multiple
endpoints of the same service type exist in the same region, use service
name as the tiebreaker.
The service name attribute identifies each unique service in the catalog. Once a service
is created, its name does not change. However, new services of the same service type
may be added to the catalog with new names.
Important
If you are programmatically parsing an authentication response, use
service type rather than service name as the basis for determining whether
17
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
a user has access to a particular kind of service. Service type is stable across
all releases. New service types may be developed, but existing service types
are not renamed. In this example, type="compute" identifies all the
available compute services, one of which is named cloudServers and one of
which is named cloudServersOpenStack. New compute service names may
be added in future releases. Whatever the compute services are named,
you can always recognize them by parsing for type="compute" in the
authentication response's service catalog.
A service may expose endpoints in different regions. Regional endpoints allow clients
to provision resources in a manner that provides high availability.
Some services are not region-specific. These services supply a single non-regional
endpoint and do not provide access to internal URLs.
An endpoint can be assigned public and internal URLs. A public URL is accessible from
anywhere. Access to a public URL usually incurs traffic charges. Internal URLs are
only accessible to services within the same region. Access to an internal URL is free of
charge.
Authentication tokens are typically valid for 24 hours. Applications should be designed to
re-authenticate after receiving a 401 (Unauthorized) response from a service endpoint.
Important
If you are programmatically parsing an authentication response, please be
aware that service names are stable for the life of the particular service and
can be used as keys. You should also be aware that a user's service catalog can
include multiple uniquely-named services which perform similar functions. For
example, cloudServersOpenStack is the OpenStack version of compute whereas
cloudServers is the legacy version of compute. The same user can have access
to both services. In Auth 2.0, the service type attribute can be used as a key by
which to recognize similar services.
Tip
Beginning with Auth 2.0, the service catalog includes a service type attribute to
identify services that perform similar functions but have different names. For
example, type="compute" identifies compute services such as cloudServers
and cloudServersOpenStack. Some developers have found the service type
attribute to be useful in parsing the service catalog. For additional information
on Auth 2.0 (also known as the Cloud Identity Service), refer to the Cloud
Identity Client Developer Guide at http://docs.rackspace.com/.
Cloud Files service endpoints are published in the service catalog in the Auth response
with the account information, which is a required element of the service endpoints. The
examples shown here are for authentication for US customers. Customers with UK-based
18
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
accounts will see different values in the service catalog. Refer to Section 3.3, “Service Access
Endpoints” [20] for more information about service endpoints.
See the Cloud Identity Client Developer Guide for information about how to perform the
following tasks:
Note
The account owner (identity:user-admin) role cannot hold any additional roles
because it already has full access to all capabilities.
Additionally, two multiproduct roles apply to all products. Users with multiproduct
roles inherit access to future products when those products become RBAC-enabled. The
following table describes these roles and their permissions.
19
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
The following table shows two examples of how potential conflicts between user roles in
the Control Panel are resolved:
Permission Configuration View of Permission Can the User Perform Product Admin
in the Control Panel Functions in the Control Panel?
User is assigned the following roles: Appears that the user has only the Yes, for Cloud Files only. The user has
multiproduct observer and Cloud Files multiproduct observer role the observer role for the rest of the
admin products.
User is assigned the following roles: Appears that the user has only the Yes, for all of the products. The Cloud
multiproduct admin and Cloud Files multiproduct admin role Files observer role is ignored.
observer
The endpoints to use for the storage service component of your Cloud Files API calls are
summarized in the table below.
20
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Region Endpoint
https://snet-storage101.dfw1.clouddrive.com/
v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/
Hong Kong (HKG) https://storage101.hkg1.clouddrive.com/
v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/
https://snet-storage101.hkg1.clouddrive.com/
v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/
London (LON) https://storage101.lon3.clouddrive.com/
v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/
https://snet-storage101.lon3.clouddrive.com/
v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/
Northern Virginia (IAD) https://storage101.iad3.clouddrive.com/
v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/
https://snet-storage101.iad3.clouddrive.com/
v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/
Sydney (SYD) https://storage101.syd2.clouddrive.com/
v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/
https://snet-storage101.syd2.clouddrive.com/
v1/MossoCloudFS_aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/
Replace the sample MossoCloudFS information in the table above with the actual
MossoCloudFS information returned as part of the authentication service response. You
will find this after the final '/' in the publicURL field and the internalURL field in the
cloudFiles section of the service catalog returned by the authentication response. For
more information about the account number, see the sample authentication request and
response in Section 3.1.2, “Retrieving the Authentication Token” [10] as well as the
Cloud Identity Client Developer Guide.
Tip
If you do not know which data center you are working in or your account ID,
you can find them in your Cloud Control Panel at mycloud.rackspace.com.
If you are working with cloud servers that are in one of the Rackspace data centers, using
the ServiceNet endpoint in the same data center has no network costs and provides a faster
connection. ServiceNet endpoints are prefixed with snet- in Table 3.3, “Regionalized
Service Endpoints for Storage Services ” [20]. ServiceNet is the data center internet
network. In your authentication response, it is listed as internalURL.
If you are working with servers that are not in one of the Rackspace data centers, you must
use a public endpoint to connect. In your authentication response, public endpoints are
listed as publicURL. If you are working with servers in multiple data centers or have a
mixed environment where you have servers in your data centers and in Rackspace data
centers, use a public endpoint because it is accessible from all the servers in the different
environments.
Note
In order to avoid external bandwidth charges, your containers and servers must
be in the same data center.
You might find it useful to locate your objects in more than one data center to
keep track of your data and backups. Specifically, if you serve an audience in a
21
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
particular region, you might find it helpful to locate your Cloud Files objects as
close to that region as possible.
The endpoints to use for the CDN management service component of your Cloud Files API
calls are summarized in the table below.
Note
If your audience is world wide, you might consider using the Akamai Content
Delivery Network (CDN). The CDN speeds your content delivery because it is
cached at edge locations around the globe, rather than being served from a
single origin server. You can learn more about CDN-enabling your containers in
Section 9.2.1, “CDN-Enable and CDN-Disable a Container” [86].
As with the storage component service, replace the sample MossoCloudFS information
with the actual MossoCloudFS information returned as part of the authentication service
response. For the CDN management service, you will find this information after the final '/'
in the publicURL field in the cloudFilesCDN section of the service catalog returned by
the authentication response.
The contract version denotes the data model and behavior that the API supports. The
requested contract version is included in all request URIs. Different contract versions of the
API may be available at any given time and are not guaranteed to be compatible with one
another.
Note
This document pertains to contract version 1.
22
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
3.5. Absolute Limits
Absolute limits are fixed. Absolute limits control the total number of specific objects that
the user can have or process in Cloud Files.
Table 3.5. Absolute Limits
Name Description Limit
Containers per account Maximum number of containers per account 500,000 containers
Container listing Maximum number of containers that can be listed at 10,000 containers
one time
Pseudo hierarchical folders and Simulated hierarchical structure within a single No limit
directories container by adding forward slash characters (/) in
the object name
Container and object metadata Maximum metadata limits 4096 bytes maximum overall
limits metadata, with 90 distinct
metadata items at the
most. Each may have a 128
character name length with
a 256 max value length
each.
Number of object segments per Maximum number of object segments per SLO 1,000 object segments
Static Large Object (SLO)
TTL for a CDN-enabled container Maximum TTL for a CDN-enabled container 1 year -31536000 seconds
Container name length Maximum length of container name 256 bytes
Object name length Maximum length of object name 1024 bytes
Upload limit for a request Maximum object size for an upload in a single 5 GB (For larger files, see
request Section 8.2.2, “Static Large
Object Creation” [74])
or Section 8.2.1,
“Dynamic Large Object
Creation” [72].)
CDN file size limit Maximum size of file that can be served from CDN 10 GB
Rate limit for write operations Maximum number of write operations per second 100 operations per second
per container, where a write operation is a COPY,
DELETE, POST, or PUT. If you reach this rate limit,
Cloud Files slows the processing of write requests for
the container to 100 operations per second.
You specify the response format in requests by using the Accept header. The Cloud Files
API supports both the JSON (application/json) and XML (application/xml) data
serialization formats, as well as other formats such as text/plain and text/xml .
23
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Container and object names must be UTF-8 encoded and then should be properly URL-
encoded prior to interacting with the REST interface. You might be using an API binding
that performs the URL-encoding on your behalf. If so, do not URL-encode before calling the
API binding, or you will double-encode container and object names. The length restrictions
should be checked against the URL-encoded string.
Note
The language-specific APIs handle URL-encoding and decoding.
Each REST request against Cloud Files requires the inclusion of an authorization token in
the HTTP header X-Auth-Token. Clients obtain this token, along with the Cloud Files
URIs, by first using the Rackspace authentication service and supplying a valid user name
and API access key. For more information, see Section 3.1, “Authentication” [10].
The two sets of REST services that make up the full Cloud Files product are:
• Storage Service: The REST service identified with cloudFiles in the service catalog (see
Section 3.1.2, “Retrieving the Authentication Token” [10]) manages the data storage in
the system. Example operations are creating containers and uploading objects.
• CDN Service: The REST service identified with cloudFilesCDN in the service catalog
(see Section 3.1.2, “Retrieving the Authentication Token” [10]) manages the CDN feature
of Cloud Files.
24
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
In the following sections, the purpose of each HTTP method depends upon which service
the call is made against. For example, a PUT request against one of the cloudFiles
endpoints can be used to create a container or upload an object, while a PUT request
against the one of the cloufFilesCDN endpoints is used to CDN-enable a container.
The language-specific APIs mask this system separation from the programmer. They simply
create a container and mark it public and handle calling the appropriate back-end services
by using the appropriate REST APIs.
Note
All requests to authenticate and operate against Cloud Files are performed
using SSL over HTTP (HTTPS) on TCP port 443.
The following diagram illustrates the various system interfaces and the ease with which
content can be distributed over the CDN. The process is simple: authenticate, create a
container, upload objects, mark the container as public, and begin serving that content
from a powerful CDN.
Note
Marking the container as public simply means enabling the container to be
distributed over the CDN. A CDN-enabled container is publicly accessible.
1 . Au t h e n t ica t e
2 . Cr e a t e Con t a in e r
Ra ck sp a ce Clou d a n d Up loa d Ob je ct s
Au t h e n t ica t ion
Se r vice
4 . Se r ve Con t e n t
3 . M a r k Con t a in e r s Pu b lic
CD N M a n a g e m e n t St or a g e
Se r vice Se r vice
25
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
All requests are directed to the endpoints described in the cloudFiles section of the
service catalog obtained during successful authentication. (For more information, see
Section 3.1, “Authentication” [10] and Section 3.3, “Service Access Endpoints” [20].)
• Container names may not exceed 256 bytes and cannot contain a '/' character.
• Object names may not exceed 1024 bytes, but they have no character restrictions.
The following sections describe the operations that you can perform within the storage
system:
• Section 5.1, “Account Services” [27] describes operations that you can perform at the
account level of the storage system.
• Section 5.2, “Container Services” [36] describes operations that you can perform on
containers.
• Section 5.3, “Object Services” [50] describes operations that you can perform on
objects.
26
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
5.1. Account Services
You can perform the operations in the following table at the account level of your Cloud
Files account.
For your own requests, you must use your own account information and authentication
token. You can check how to generate an authentication token in Section 3.1.2,
“Retrieving the Authentication Token” [10]. Your authentication token and your account
information are in the service catalog that is produced.
27
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
This operation lists the storage containers in your account and sorts them by name.
The container is the basic storage unit in Cloud Files. To view a list of the containers in your
account, perform a GET operation against your storage account URL.
The list is limited to 10,000 containers at a time. See "Controlling a Large List of Containers"
below for information on limiting and navigating the list.
A list of containers is returned in the response body, one container per line.
The character sequence used to create the newline that separates the container
names is a single \n. If you want to parse these listings, you should send an Accept:
application/json or Accept: application/xml header with the request to get
the results in JSON or XML.
The HTTP response status code is a value from 200 to 299, inclusive. A 200 (OK) code
returns if there are containers, and a 204 (No Content) code returns if there are no
containers.
A GET operation on the storage account URL returns a list of up to 10,000 container
names. You can control and limit this list of results by using the marker, end_marker, and
limit parameters. These parameters provide a mechanism to iterate through the entire
list of containers.
The marker parameter tells Cloud Files where to begin your list of containers and
end_marker specifies where to end the list. You can use them independently or together,
separated by an ampersand (&). If you do not specify them, your list displays up to 10,000
containers. Note that the marker and end_marker values should be URL-encoded prior
to sending the HTTP request.
You can use the limit parameter to reduce the number of returned objects.
28
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
If the number of returned items equals the limit used (or 10,000 if no limit was
specified), you can assume there are more object names.
Note
At this time, a prefix query parameter is not supported at the account level.
As an example, start with an account that has five container names, as follows:
apples
bananas
kiwis
oranges
pears
GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123?limit=2
Host: storage.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
apples
bananas
Because the operation returned two items, assume there are more container names to list
and make another request with a marker of the last item returned:
GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123?limit=2&marker=
bananas
Host: storage.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
kiwis
oranges
Again, two items are returned, and you assume that there may be more. So you make
another GET request for two more.
GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123?limit=2&marker=
oranges
Host: storage.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
pears
This one-item response shows less than the limit of 2 container names requested, and
indicates that this is the end of the list.
By using end_marker, you can limit the result set to container names less than the given
value.
29
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123?end_marker=oranges
Host: storage.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
apples
bananas
kiwis
5.1.1.1. Request
This table shows the URI parameters for the List Account Containers Request:
This table shows the Query parameters for the List Account Containers Request:
(Optional)
marker String Given a string value x, returns container names greater in value than
the specified marker. Only strings using UTF-8 encoding are valid.
(Optional)
end_marker String Given a string value x, returns container names less in value than the
specified marker. Only strings using UTF-8 encoding are valid.
(Optional)
format String Value of the serialized response format - either json or xml.
(Optional)
5.1.1.2. Response
This table shows the Body parameters for the List Account Containers Response:
(Required)
30
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
(Required)
bytes Int Number of bytes in the container.
(Required)
<account name="name">
<container>
<name>test_container_1</name>
<count>2</count>
<bytes>78</bytes>
</container>
<container>
<name>test_container_2</name>
<count>1</count>
<bytes>17</bytes>
</container>
</account>
[
{"name":"test_container_1", "count":2, "bytes":78},
{"name":"test_container_2", "count":1, "bytes":17}
]
31
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
You can associate custom metadata headers with the account level URI. To create or
update an account metadata header, submit a POST operation. These headers must have
the format X-Account-Meta-name. Replace name with name of your metadata. (In
the example request below, the metadata headers are X-Account-Meta-Book and X-
Account_Meta-Subject.)
Subsequent POST operations for the same key/value pair overwrite the previous value.
A status code of 2xx (between 200 and 299, inclusive) indicates success.
This operation does not require a request body and does not return a response body.
To confirm your metadata changes, you can perform a HEAD operation on the account.
(For information, see Section 5.1.3, “Get Account Metadata” [34].) Do not send the
metadata in your HEAD operation.
5.1.2.1. Request
This table shows the Header parameters for the Create or Update Account Metadata
Request:
This table shows the URI parameters for the Create or Update Account Metadata Request:
5.1.2.2. Response
Example 5.6. Create or Update Account Metadata Response
HTTP/1.1 204 No Content
Content-Length: 0
32
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
33
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Perform a HEAD operation on your storage account URL to get the following information:
The HTTP return code is 2xx (between 200 and 299, inclusive) if the request succeeds. In
the example, a 204 (No Content) code is returned. A 401 (Unauthorized) is returned for an
invalid account or authentication token.
This operation does not require a request body and does not return a response body.
5.1.3.1. Request
This table shows the URI parameters for the Get Account Metadata Request:
5.1.3.2. Response
This table shows the Header parameters for the Get Account Metadata Response:
34
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
X-Account-Object-Count: 573
X-Timestamp: 1369081921.78518
X-Account-Meta-Temp-Url-Key: ed6a04a9f70458575112811a9af5284e
X-Account-Bytes-Used: 14268918
X-Account-Container-Count: 1
Content-Type: text/plain; charset=utf-8
Accept-Ranges: bytes
X-Trans-Id: tx8e82a77399724e40a90e8-0052cf0e52dfw1
Date: Thu, 09 Jan 2014 21:02:10 GMT
35
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
To delete a metadata header, use the POST operation to send an empty value for that
particular header.
If the tool you use to communicate with Cloud Files does not support empty headers, such
as an older version of cURL, send the X-Remove-Account-Meta-name: arbitrary
value header. The arbitrary value is ignored. In the example request below, X-
Remove-Account-Meta-Book: x is used.
A status code of 2xx (between 200 and 299, inclusive) indicates success.
This operation does not require a request body and does not return a response body.
5.1.4.1. Request
This table shows the Header parameters for the Delete Account Metadata Request:
Name Type Description
X-Remove-Account-Meta- String Header to send to delete account metadata. Replace the name at the
name end of the header with the name for your metadata.
(Required)
This table shows the URI parameters for the Delete Account Metadata Request:
Name Type Description
{account} String Your unique account identifier.
5.1.4.2. Response
Example 5.10. Delete Account Metadata Response
HTTP/1.1 204 No Content
Content-Length: 0
Content-Type: text/html; charset=UTF-8
X-Trans-Id: txe749a717ee5e4da7a6895-0052cf2286dfw1
Date: Thu, 09 Jan 2014 22:28:22 GMT
5.2. Container Services
You can perform the operations in the following table on containers in your Cloud Files
account.
36
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
For your own requests, you must use your own account information, authentication
token, and container name. You can check how to generate an authentication token in
Section 3.1.2, “Retrieving the Authentication Token” [10]. Your authentication token and
your account information are in the service catalog that is produced.
37
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
This operation against a storage container name retrieves a list of objects stored in the
container. Additionally, you can use optional query parameters to refine the list results.
A request with no query parameters returns the full list of object names stored in the
container, up to 10,000 names. The response body shows the object names as one object
name per line. Specifying the query parameters filters the full list and returns a subset of
objects. For information on limiting and controlling the list, see the following “Controlling a
Large List of Objects” section.
The HTTP response status code is a value from 200 to 299, inclusive. A status code of 200
(OK) is returned if there are objects, and a 204 (No Content) is returned if there are no
objects. If the container does not exist, or if an incorrect account is specified, a status code
404 (Not Found) is returned.
For information on filtering the results of a container list, see Chapter 6, “Pseudo
Hierarchical Folders and Directories” [66].
If you append the format=xml or the format=json query parameter to the storage
account URL, the service returns additional object information serialized in the specified
format. The status codes are the same when using format=xml or format=json.
However, Content-Type matches the specified format. The example responses below are
formatted for readability.
A GET request against the container account URL returns a list of up to 10,000 objects. You
can limit and control this list of results by using the marker, end_marker, and limit
parameters.
The marker parameter tells Cloud Files where to begin your list of objects, and
end_marker tells where to end the list. You can use them either independently or
together, separated by an ampersand (&). If you do not specify them, your list displays up
to 10,000 objects. Note that the marker and end_marker values should be URL-encoded
prior to sending the HTTP request.
You can use the limit parameter to reduce the number of returned objects.
If the number of returned items equals the limit used (or 10,000 if no limit was
specified), you can assume there are more object names.
gala
38
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
grannysmith
honeycrisp
jonagold
reddelicious
GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/AppleType?limit=2
Host: storage.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
gala
grannysmith
Because the request returned two items, assume there are more object names to list and
make another request with a marker of the last item returned:
GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/AppleType?limit=2&
marker=grannysmith
Host: storage.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
honeycrisp
jonagold
Again, two items are returned, and you assume that there may be more. So you make
another GET request for two more.
GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/AppleType?limit=2&
marker=jonagold
Host: storage.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
reddelicious
This one-item response shows less than the limit of two object names requested, and
indicates that this is the end of the list.
5.2.1.1. Request
This table shows the URI parameters for the List Container Objects Request:
This table shows the Query parameters for the List Container Objects Request:
39
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
(Optional)
marker String Given a string value x, returns object names greater in value than the
specified marker.
(Optional)
end_marker String Given a string value x, returns object names less in value than the
specified marker.
(Optional)
prefix String For a string value x, causes the results to be limited to object names
beginning with the substring x.
(Optional)
format String Specifies either json or xml to return the respective serialized response.
(Optional)
delimiter Char For a character c, returns the object names nested in the container
(without the need for the directory marker objects).
(Optional)
path String For a string x, returns the object names nested in the pseudo path.
Equivalent to setting delimiter to '/' and prefix to the path with a '/' on
(Optional) the end. For more information about pseudo paths, see the section on
pseudo hierarchical folders and directories.
5.2.1.2. Response
This table shows the Header parameters for the List Container Objects Response:
40
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
41
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
5.2.2. Create Container
This operation creates a Cloud Files container. Containers are storage compartments for
your data. The URL-encoded name must be less than 256 bytes and cannot contain a
forward slash character (/). You can create up to 500,000 containers in your Cloud Files
account.
You can assign custom metadata for containers by including additional HTTP headers with
an X-Container-Meta- prefix on the POST request. See Section 5.2.4, “Create or Update
Container Metadata” [45] for details on setting custom metadata.
Using custom container metadata, you can create information in the header to effectively
tag a container with metadata. The container metadata restrictions are the same as object
metadata. You can have 4096 bytes maximum of overall metadata, with a maximum of
90 distinct metadata items. Each can have a name length of up to 128 characters with a
maximum of 256 bytes in the value. Any valid UTF-8 encoded string value is allowed for
metadata. In addition for custom metadata, we recommend that you URL-encode any non-
ASCII values using a "%" symbol, followed by the two-digit hexadecimal ISO-Latin code for
the character.
A status code of 201 (Created) indicates that the container was created as requested.
Container PUT requests are idempotent, and a code of 202 (Accepted) is returned if the
container existed prior to the request. If you request a PUT to a container with an X-
Container-Meta- prefix in the header, your GET or HEAD request responses carry the
metadata prefix from the container in subsequent requests.
This operation does not require a request body and does not return a response body.
5.2.2.1. Request
This table shows the Header parameters for the Create Container Request:
This table shows the URI parameters for the Create Container Request:
42
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
5.2.2.2. Response
Example 5.19. Create Container Response
HTTP/1.1 201 Created
Date: Thu, 07 Jun 2007 18:50:19 GMT
Content-Type: text/plain; charset=UTF-8
43
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
5.2.3. Delete Container
A DELETE operation against a storage container permanently removes it. The container
must be empty before it can be deleted.
Before using DELETE, you can use a GET operation against the container to list any objects
it contains. (See Section 5.2.1, “List Container Objects” [38].)
A status code of 204 (No Content) indicates success. A status code of 404 (Not Found) is
returned if the requested container is not found. A status code of 409 (Conflict) is returned
if the container is not empty.
This operation does not require a request body and does not return a response body.
5.2.3.1. Request
This table shows the URI parameters for the Delete Container Request:
5.2.3.2. Response
Example 5.22. Delete Container Response
HTTP/1.1 204 No Content
Date: Thu, 07 Jun 2007 18:57:07 GMT
Content-Length: 0
Content-Type: text/plain; charset=UTF-8
44
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
To set or edit container metadata, perform a POST operation to the container. The
operation must include X-Container-Meta-name, where name is the name of your
custom metadata. Subsequent POSTPOST to the header using the same metadata name
overwrite the previous value.
To view your metadata changes, perform a HEAD operation on the container. (For more
information, see Section 5.2.5, “Get Container Metadata” [47].) Do not try to send the
metadata in your HEAD request.
A status code of 204 (No Content) indicates success. Status code 404 (Not Found) is
returned when the requested container does not exist.
This operation does not require a request body and does not return a response body.
Note
For information about adding metadata for the following purposes, see
Chapter 7, “Additional Container Services Information” [68]:
• Container quotas
• Access log delivery
5.2.4.1. Request
This table shows the Header parameters for the Create or Update Container Metadata
Request:
Name Type Description
X-Container-Meta-name String The container metadata. Replace the name at the end of the header
with the name of your metadata.
(Required)
This table shows the URI parameters for the Create or Update Container Metadata
Request:
Name Type Description
{account} String Your unique account identifier.
{container} String The unique identifier of the container.
45
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
1.1
Host: storage.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
X-Container-Meta-Book: MobyDick
X-Container-Meta-Subject: Whaling
5.2.4.2. Response
Example 5.24. Create or Update Container Metadata Response
HTTP/1.1 204 No Content
Date: Thu, 07 Mar 2012 20:42:51 GMT
Content-Length: 0
Content-Type: text/plain; charset=UTF-8
46
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Use a HEAD operation against the container to return the following metadata:
To set and edit your custom metadata, see Section 5.2.4, “Create or Update Container
Metadata” [45].
If the container exists, a status code of 2xx (between 200 and 299, inclusive) is returned. If
the container does not exist, a status code of 404 (Not Found) is returned.
This operation does not require a request body and does not return a response body.
5.2.5.1. Request
This table shows the URI parameters for the Get Container Metadata Request:
5.2.5.2. Response
This table shows the Header parameters for the Get Container Metadata Response:
(Required)
X-Container-Bytes-Used Int The total number of bytes used for all objects in the container.
(Required)
X-Container-Meta-name String Any metadata set on the container. The name at the end of the
header is the name of your metadata.
(Required)
47
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
48
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
To delete a metadata header, use POST to send an empty value for that particular header,
such as X-Container-Meta-Subject:.
If the tool you are using to communicate with Cloud Files does not support sending empty
headers (such as older versions of cURL), send the header X-Remove-Container-Meta-
name: arbitrary value, where name is the name of your custom header. arbitrary
value can be any value, and it will not be used.
To set and edit your custom metadata, see Section 5.2.4, “Create or Update Container
Metadata” [45].
A status code of 2xx (between 200 and 299, inclusive) indicates success. If the container
does not exist, a status code of 404 (Not Found) is returned.
This operation does not require a request body and does not return a response body.
5.2.6.1. Request
This table shows the Header parameters for the Delete Container Metadata Request:
This table shows the URI parameters for the Delete Container Metadata Request:
5.2.6.2. Response
Example 5.28. Delete Container Metadata Response
HTTP/1.1 204 No Content
49
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
5.3. Object Services
You can perform the operations in the following table on objects in your Cloud Files
containers.
For your own requests, you must use your own account information, authentication token,
container name, and object name. You can check how to generate an authentication token
in Section 3.1.2, “Retrieving the Authentication Token” [10]. Your authentication token
and your account information are in the service catalog that is produced.
50
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
You can perform conditional GET requests by using the following HTTP headers in the
request:
• If-Match
• If-None-Match
• If-Modified-Since
• If-Unmodified-Since
You can fetch a portion of the data by using the HTTP Range header. To specify multiple
ranges, separate the range specifications with a comma.
• Suffix byte range specification: Use LENGTH bytes to specify the length of the data
range.
The following table shows forms of the header and the ranges of data specified.
Object data is returned in the response body. Object metadata is returned as HTTP headers.
A status code of 2xx (between 200 and 299, inclusive) indicates success. Status code 404
(Not Found) is returned if the object does not exist.
51
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Note
In the examples that follow that use ranges, the object contains the 10 bytes of
data 0123456789.
5.3.1.1. Request
This table shows the URI parameters for the Get Object Data Request:
Name Type Description
{account} String Your unique account identifier.
{container} String The unique identifier of the container.
{object} String The unique identifier of the object.
5.3.1.2. Response
Example 5.32. Get Object Data Response
HTTP/1.1 200 OK
Date: Wed, 14 Jul 2010 19:37:41 GMT
Last-Modified: Mon, 12 Jun 2010 13:40:18 GMT
ETag: b0dffe8254d152d8fd28f3c5e0404a10
Content-Type: text/html
Content-Length: 512000
[ ...object content... ]
52
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
456
--4789b20f24cc4d2a8da2e552e151e6fe
Content-Type: application/octet-stream
Content-Range: bytes 1-3/10
123
--4789b20f24cc4d2a8da2e552e151e6fe
Content-Type: application/octet-stream
Content-Range: bytes 2-5/10
2345
--4789b20f24cc4d2a8da2e552e151e6fe--
53
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
You can ensure end-to-end data integrity by including an MD5 checksum of your object's
data in the ETag header. You are not required to include the ETag header, but we
recommend its use to ensure that the storage system successfully stores your object's
content.
You can cause an object to expire after a certain date and time by using the X-Delete-
At or X-Delete-After headers during an object PUT operation. The X-Delete-
At header requires a Unix Epoch timestamp, in integer form. For example, 1348691905
represents Wed, 26 Sep 2012 20:38:25 GMT. By setting the header to a specific Epoch
time, you indicate when you want the object to expire, not be served, and be deleted
completely from the storage system. When Cloud Files detects one of these headers, the
system automatically stops serving that object at the specified date and time, and shortly
after the expiration date, it removes the object from the storage system.
The HTTP response includes the MD5 checksum of the data written to the storage system.
If you do not send the ETag in the request, you should compare the value returned with
your content's MD5 locally to perform the end-to-end data validation on the client side. For
manifest objects, the ETag is the MD5 checksum of the concatenated string of ETags for
each segment in the manifest, which offers change detection but not direct comparison.
Note
The best checks for a successful upload are to check the ETag match with a
checksum and to see if you get a 404 (Not Found) status code when you do a
GET, HEAD, POST, or DELETE.
Objects can be assigned custom metadata by including additional HTTP headers in the PUT
request. To assign custom metadata, use an HTTP header with the X-Object-Meta-
prefix.
You can also specify Content-Type for your object. For example, you can specify
Content-Type: audio/mpeg3 for mp3 files.
A status code of 201 (Created) indicates a successful write. Any status code in the 400
range denotes failure. The 401 (Unauthorized) status code is returned upon authentication
failure. The 411 (Length Required) status code denotes a missing Content-Length or
Content-Type header in the request. If the MD5 checksum of the data written to the
storage system does NOT match the optionally supplied ETag value, a 422 (Unprocessable
Entity) status code is returned.
54
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
5.3.2.1. Request
This table shows the Header parameters for the Create or Update Object Request:
(Optional)
Content-Type String The media type of the entity-body sent. If not specified, the
Content-Type is guessed, by using the Python mimetypes library,
(Optional) based on the object path.
Content-Disposition String The new browser behavior for the file, so that the downloader can
save the file rather than displaying it using default browser settings.
(Optional)
Content-Encoding String The underlying media type of the compressed file.
(Optional)
X-Delete-At Int The certain date, in the format of a Unix Epoch timestamp, when the
object will be removed.
(Optional)
X-Delete-After Int The certain date, in the format of a Unix Epoch timestamp, after which
the object will be removed.
(Optional)
X-Object-Meta-name String The custom object metadata. name at the end of this header
represents the name of your metadata.
(Optional)
X-Detect-Content-Type String If you set this header to True, the Content-Type that is sent in the
request (if any) is ignored, and Content-Type is guessed by using
(Optional) the Python mimetypes library based on the object path.
This table shows the URI parameters for the Create or Update Object Request:
[ ...object content... ]
55
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
5.3.2.2. Response
Example 5.36. Create or Update Object Response
HTTP/1.1 201 Created
Date: Thu, 07 Jun 2010 18:57:07 GMT
ETag: d9f5eb4bba4e2f2f046e54611bc8196b
Content-Length: 0
Content-Type: text/plain; charset=UTF-8
56
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
5.3.3. Delete Object
DELETE operations on an object permanently remove an object from the storage system
(data and metadata).
Deleting an object is processed immediately at the time of the request. Any subsequent
GET, HEAD, POST, or DELETE operations return a 404 (Not Found) error unless object
versioning is on and other versions exist. For more information about object versioning, see
Section 8.6, “Object Versioning” [79].
A status code of 204 (No Content) indicates success. Status code 404 (Not Found) is
returned when the object does not exist.
This operation does not require a request body and does not return a response body.
For information about bulk deletions, see Section 12.3, “Bulk Delete” [104].
5.3.3.1. Request
This table shows the URI parameters for the Delete Object Request:
5.3.3.2. Response
Example 5.38. Delete Object Response
HTTP/1.1 204 No Content
57
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
58
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
5.3.4. Copy Object
Suppose you upload a file with the wrong object name or content type, or you need to
move some objects to another container. Without a server-side object copy feature, you
would need to repeat uploading the same content and then delete the existing object.
With a server-side object copy feature, you can save the step of re-uploading the content
and thus also save the associated bandwidth charges, if any were to apply.
There are two ways to copy an existing object to another object in Cloud Files.
One way is to use a PUT request to the new object (the destination) location, but add the
X-Copy-From header to designate the source of the data. The header value should be the
container and object name of the source object in the form of /container/object. The
HTTP specification of a PUT request with the X-Copy-From header requires a Content-
Length header, but the storage system does not use the Content-Length to perform
the operation. For this reason, you can simply send a Content-Length of zero (0).
Note
You cannot copy an object larger than 5 GB (by default). For more information
about how to handle objects larger than 5 GB, see Section 8.2, “Create Large
Objects” [70].
The second way to perform an object copy is similar. Use a COPY request to the existing
object, and include the Destination header to specify the destination of the copy. The
header value is the container and new object name in the form of /container/object.
Unlike the first method, this method does not require a Content-Length header.
59
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
With both of these methods, the destination container must exist before attempting the
copy.
Note
If you are copying many objects, you can improve the total copy time by
issuing several concurrent COPY commands. Because Cloud Files is a distributed
storage system, your concurrent COPY commands run on separate machines
simultaneously, which is much better than waiting for one copy to finish before
starting the next COPY command. As a rule of thumb, you can run up to 100
concurrent COPY commands per container (running more will have diminishing
improvement).
Another option is bulk importing of data. For information about bulk imports,
see Section 12.1, “Bulk Importing of Data” [102].
If you want to move the object rather than copy it, send a DELETE request to the source
object after copying it. A move is simply a COPY followed by a DELETE. All metadata is
preserved during the object copy. Note that you can set metadata on the request to copy
the object (with either the PUT or the COPY) and the metadata overwrites any conflicting
keys on the destination object.
Your account is not charged when you copy or move your objects within the same data
center using the internal network URI, ServiceNet, as the storage URL. You can find your
ServiceNet endpoint in the service catalog created when you authenticate your session. For
information on how to authenticate your session, see Section 3.1, “Authentication” [10].
As shown in the partial service catalog example below, the ServiceNet URI is listed as
internalURL. The name is your Cloud Files storage URL with snet- pre-pended to it. If
you do not know which data center you are working in, you can find it in the Cloud Control
Panel. (For more information about service access endpoints, see Section 3.3, “Service
Access Endpoints” [20].)
"endpoints": [
{
"region": "DFW",
"internalURL": "https://snet-storage101.dfw1.clouddrive.com/v1/
MossoCloudFS_9491081f-7e12-4f56-98d0-cdb3037c8d7c",
"tenantId": "MossoCloudFS_9491081f-7e12-4f56-98d0-cdb3037c8d7c",
"publicURL": "https://storage101.dfw1.clouddrive.com/v1/
MossoCloudFS_9491081f-7e12-4f56-98d0-cdb3037c8d7c"
},
{
"region": "ORD",
"internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/
MossoCloudFS_9491081f-7e12-4f56-98d0-cdb3037c8d7c",
"tenantId": "MossoCloudFS_9491081f-7e12-4f56-98d0-cdb3037c8d7c",
"publicURL": "https://storage101.ord1.clouddrive.com/v1/
MossoCloudFS_9491081f-7e12-4f56-98d0-cdb3037c8d7c"
60
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
}
]
5.3.4.1. Request
This table shows the Header parameters for the Copy Object Request:
This table shows the URI parameters for the Copy Object Request:
5.3.4.2. Response
This operation does not return a response body.
61
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
HEAD operations on an object are used to retrieve object metadata and other standard
HTTP headers.
The only required header to be sent in the request is X-Auth-Token for the authorization
token.
A status code of 200 (OK) indicates success. Status code 404 (Not Found) is returned when
the object does not exist.
This operation does not return a response body. Metadata is returned as HTTP headers.
Note
The HEAD return code for an object is different than that of a container.
The HEAD request does not return a message body in the response, so a 2xx
status code denotes success. When a HEAD request is performed against
the container, it queries the container databases, and it does not retrieve
the content from them. Thus, this returns the 204 (No Content) status code.
However, when a HEAD request is performed against the object, it returns a
200 OK status code because it can view the content.
5.3.5.1. Request
This table shows the URI parameters for the Get Object Metadata Request:
Name Type Description
{account} String Your unique account identifier.
{container} String The unique identifier of the container.
{object} String The unique identifier of the object.
5.3.5.2. Response
This table shows the Header parameters for the Get Object Metadata Response:
Name Type Description
X-Timestamp String An internal variable that indicates the last time an entity (account,
container, or object) was modified. The format is the same as a Unix
62
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
63
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
You can set or update your custom metadata for existing objects by using a POST request
to the object name.
To remove previously-set object metadata, perform a POST request to the object name
with X-Remove-Object-Meta-name: Foo where name is the name of your metadata.
Foo is any term, and it will not be used. You must, however, send some value with the
request. Otherwise, the metadata is not removed.
For information on working with metadata when copying objects, see Section 5.3.4, “Copy
Object” [59].
To remove all metadata on an object, simply perform a POST request for the
object with no metadata specified. However, to remove container metadata,
you must send the header with an empty value.
A status code of 202 (Accepted) indicates success. Status code 404 (Not Found) is returned
if the requested object does not exist.
5.3.6.1. Request
This table shows the Header parameters for the Update Object Metadata Request:
64
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
This table shows the URI parameters for the Update Object Metadata Request:
5.3.6.2. Response
Example 5.47. Update Object Metadata Response
HTTP/1.1 202 Accepted
Date: Thu, 07 Jun 2007 20:59:39 GMT
Content-Length: 0
Content-Type: text/plain; charset=UTF-8
65
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Note
In the example below, the objects reside in a container called backups. Within
that container, the objects are organized in a pseudo directory called photos.
Keep in mind that the container name is not displayed in the example, but
that it is a part of the object URIs. For instance, the URI of the picture me.jpg
is https://storage.clouddrive.com/v1/CF_xer7_343/backups/
photos/me.jpg.
To display a list of all the objects in the storage container, use GET without a delimiter
or prefix.
GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/backups
The system returns status code 200 OK and the requested list of the objects.
photos/animals/cats/persian.jpg
photos/animals/cats/siamese.jpg
photos/animals/dogs/corgi.jpg
photos/animals/dogs/poodle.jpg
photos/animals/dogs/terrier.jpg
photos/me.jpg
photos/plants/fern.jpg
photos/plants/rose.jpg
Use the delimiter parameter to limit the displayed results. Any character may be used as a
delimiter. However, to use delimiter with pseudo directories, use the slash (/).
GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/backups?delimiter=/
The system returns status code 200 (OK) and the requested matching objects. Because
the request used the slash, only the pseudo directory photos/ displays. Keep in mind
that the returned values from a slash delimiter query are not real objects. They have a
Content-Type of application/directory and are in a subdir section of JSON and
XML results.
photos/
Use the prefix parameter with the delimiter parameter to view the objects inside a
pseudo directory, including further nested pseudo directories.
GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/backups?prefix=
photos/&delimiter=/
The system returns status code 200 (OK) and the objects and pseudo directories within the
top level pseudo directory.
66
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
photos/animals/
photos/plants/
photos/me.jpg
There is no limit to the amount of nested pseudo directories you can create. In order to
navigate through them, use a longer prefix parameter coupled with the delimiter
parameter. In the sample output below, there is a pseudo directory called dogs within the
pseudo directory animals. In order to navigate directly to the files contained within dogs,
enter the below command.
GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/backups?prefix=
photos/animals/dogs/&delimiter=/
The system returns status code 200 (OK) and the objects and pseudo directories within the
nested pseudo directory.
photos/animals/dogs/corgi.jpg
photos/animals/dogs/poodle.jpg
photos/animals/dogs/terrier.jpg
67
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
7.1. Container Quotas
The container_quotas middleware implements simple quotas that can be imposed on Cloud
Files containers by a user (most likely the account administrator) with the access to set
container metadata. Setting container quotas can be useful for limiting containers for non-
admin users, formpost uploads, or just as a self-imposed sanity check.
Any object PUT operations that exceed the quotas return a 413 response (request entity
too large) with a descriptive body.
Because the storage system is a true distributed system and because it accepts simultaneous
requests, the quotas may not be enforced exactly. For example, if the quota is 5 GB and
two users try to store a 5 GB file at the exact same time, both would be allowed to store
the file since at the time of both requests the container had sufficient remaining quota.
Also, for chunked file uploads, the storage system cannot reject transfers that will
eventually exceed the quota because the storage system does not know whether the end
of the file will exceed the quota.
Quotas are set by adding metadata to the container. The available metadata values are
described in the following table.
Access Log Delivery is set on the container, and every object in the container is tracked. To
enable access logs for a container, set the metadata flag X-Container-Meta-Access-
Log-Delivery flag to True. If you have multiple containers that you want to track, you
must set the metadata header to TRUE for each container. When your first log is delivered,
the container .ACCESS_LOGS is created. This container holds the access logs for every
container for which you turn on logging. Log files exist until you delete them. To turn off
logging, set X-Container-Meta-Access-Log-Delivery flag to FALSE.
68
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
example, Media is the name of the container, October 1, 2012 is the date, and 16 is the
hour the logs are from. There may be multiple files for a given hour because the storage
system splits log files based on both time and log file size. All times in the access logs are
UTC time.
Within the gzipped logs, the format of the entries is similar to National Center for
Supercomputing Applications (NCSA) combined log format, but without cookies. The
pattern is below. The dashes ("-") note fields which the NCSA combined log format
dictates be present but which Cloud Files does not capture. The format is:
69
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
If you have files that are larger than 5 GB and want to use Cloud Files, you can segment
them prior to upload, upload them to the same container, and then use a manifest file to
allow downloading of a concatenated object containing all the segmented objects. For
more information, see Section 8.2.1, “Dynamic Large Object Creation” [72].
• Segment objects: You divide your content into pieces and upload each piece into its own
object, which is a segment object.
• Manifest objects: You create a manifest object that "points to" the segment objects.
Segment objects do not have any special features and can be created, updated,
downloaded, and deleted. However, a manifest object is special – when you download, the
system concatenates the contents of the segment objects and returns this in the response
body of the request. This behavior extends to the response headers returned by GET and
HEAD operations. The Content-Length is the total size of all segment objects and
70
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
the ETag is calculated by taking the ETag value of each segment, concatenating them
together, and then returning the MD5 checksum of the result.
Note
If you use the COPY operation using a manifest object as the source, the new
object is a "normal" object (not segmented). If the total size of the source
segment objects exceeds 5GB, the COPY operation will fail. However, you can
make a duplicate of the manifest object. This new object can be larger than
5GB.
• Dynamic Large Objects: The manifest object has no content. However, it has X-Object-
Manifest metadata. The value of this is container/prefix , where container is
the name of the container where the segment objects are stored and prefix is a string
that all the segment objects have in common.
• Static Large Objects: The manifest object content is an ordered list of the names of the
segment objects in JSON format.
While both types of manifest objects have similar behavior, there are differences as
explained in the following table.
71
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
72
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Note
The eventual consistency model means that although you may have uploaded
a segment object, it may not appear in the container listing until later. If you
download the manifest before it appears in the container, it will not form part
of the content returned in response to a GET request.
To ensure that the download works correctly, you must upload all the object segments
to the same container and that ensure each object name is prefixed in such a way that
their names sort in the order in which they should be concatenated. You also create and
upload a manifest file. The manifest file is simply a zero-byte file with the extra X-Object-
Manifest: container/prefix header, where container is the container that
the object segments are in and prefix is the common prefix for all the segments. The
container and common prefix must be UTF-8 encoded and URL-encoded in the X-Object-
Manifest header.
It is best to upload all the segments first and then create or update the manifest. With this
method, the full object will not be available for downloading until the upload is complete.
Also, you can upload a new set of segments to a second location and then update the
manifest to point to this new location. During the upload of the new segments, the original
manifest will still be available to download the first set of segments.
Note
The segments are deletable by the user at any time. If a segment is deleted by
mistake, a Dynamic Large Object, having no way of knowing the segment was
ever there, ignores the deleted file, and the user is returned an incomplete file.
No response body is returned. A status code of 201 (Created) indicates a successful write.
Status code 411 (Length Required) indicates that the Content-Length header is missing.
If the MD5 checksum calculated by the storage system does NOT match the optionally
supplied ETag value, a 422 (Unprocessable Entity) status code is returned.
You can continue uploading segments as this example shows, prior to uploading the
manifest.
73
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Next, upload the manifest that you created that indicates the container in which the object
segments reside. Note that uploading additional segments after the manifest is created will
cause the concatenated object to be that much larger but you do not need to recreate the
manifest file for subsequent additional segments.
A GET request to the manifest object returns the concatenation of the objects from the
manifest.
Note
The ETag in the response for a GET or HEAD on the manifest file is the MD5
sum of the concatenated string of ETags for each of the segments in the
manifest. Usually, the ETag is the MD5 sum of the contents of the object, and
that holds true for each segment independently. But it is not meaningful to
generate such an ETag for the manifest itself, so this method was chosen to at
least offer change detection.
The response's Content-Type for a GET or HEAD request on the manifest will be the
same as the Content-Type set during the PUT request that created the manifest. You can
easily change the Content-Type by reissuing the PUT request.
74
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
• Uploads and downloads of Static Large Objects can be in different containers, which can
improve performance.
1. Divide your content into pieces and create (upload) a segment object to contain each
piece. You must record the ETag response header returned by the PUT operation.
Alternatively, you can calculate the MD5 checksum of the segment prior to uploading
and include this in the ETag request header – this ensures that the upload cannot
corrupt your data.
The maximum number of object segments per Static Large Object is 1,000. Each
segment, except for the final one, must be at least one megabyte.
2. List the name of each segment object along with its size and MD5 checksum in order.
Create a manifest object. You indicate that this is a manifest object by including
the ?multipart-manifest=put query string at the end of the manifest object name.
• etag – the ETag header from the successful 201 response of the PUT when you
uploaded the segment. This is the MD5 checksum of the segment object's data.
• size_bytes – the segment object's size in bytes. This should match the Content-
Length of that object.
The body of the PUT operation is an ordered list of files in JSON data format. The data to
be supplied for each segment is:
• etag – the ETag header from the successful 201 response of the PUT when you
uploaded the segment. This is the MD5 checksum of the segment object's data.
75
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
• size_bytes – the segment object's size in bytes. This should match the Content-
Length of that object.
Following is an example containing three segment objects. This example illustrates that
in contrast to dynamic large objects, you can use a number of containers and the object
names do not have to conform to a specific pattern.
The Content-Length request header must contain the length of the JSON content
– not the length of the segment objects. However, after the PUT operation completes,
the Content-Length metadata is set to the total length of all the object segments. A
similar situation applies to the ETag . If used in the PUT operation, it must contain the
MD5 checksum of the JSON content. The ETag metadata value is then set to be the MD5
checksum of the concatenated ETag values of the object segments. You can also set the
Content-Type request header and custom object metadata.
When the PUT operation sees the ?multipart-manifest=put query string, it reads
the request body and verifies that each segment object exists and that the sizes and ETags
match. If there is a mismatch, the PUT operation will fail.
On upload, the middleware will head every segment passed in and verify the size and
ETag of each. If any of the objects do not match (not found, size/ETag mismatch, below
minimum size), Cloud Files issues a 4xx status code. If everything does match, Cloud Files
issues a 2xx status code.
When the manifest object is uploaded, you are more or less guaranteed that every segment
in the manifest exists and that it matches the specifications. However, nothing prevents a
user from breaking the Static Large Object download by deleting or replacing a segment
referenced in the manifest. Users should use caution when handling the segments.
The order of the segments listed in the manifest determine the order in which the
segments will be concatenated on download. The manifest can reference objects in
separate containers, which improves concurrent upload speed. Objects can be referenced
by multiple manifests.
76
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
The headers from the GET or HEAD request return metadata for the manifest object as
shown below:
• Content-Length: The total size of the Static Large Object (the sum of the sizes of the
segments in the manifest)
• X-Static-Large-Object: True
• ETag: The ETag of the Static Large Object (generated the same way as Dynamic Large
Object)
The GET request with the following query parameter returns the actual manifest file
contents:
?multipart-manifest=get
The response body contains generated JSON. The resulting list will not be identically
formatted like the manifest you originally used in the PUT operation (?multipart-
manifest=put).
A DELETE operation with the following query parameter deletes all segment objects
in the manifest, and then, if all are successfully deleted, the manifest object itself. A
failure response will be similar to those for the bulk delete operation (Section 12.3, “Bulk
Delete” [104]).
?multipart-manifest=delete
A PUT overwrites the manifest object (and leaves the segments alone).
APOST changes the manifest file's metadata and contents, as with any other object.
77
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
The overall X-Container-Bytes-Used for the container (and for the account) does not
reflect the total size of the manifest, but the actual size of the stored JSON data. This allows
you to see the total size of the Static Large Object in a container listing, but does not inflate
the bytes used for the container or the account.
The object must be compressed before it is uploaded. Cloud Files does not do any
automatic compression. The Content-Encoding header enables the client to set the
metadata appropriately.
In the following example, the Content-Encoding header indicates the type of encoding
used on the data.
78
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
for objects that you do not want to permanently store, such as log files, recurring full
backups of a dataset, or documents or images that you know will be outdated at a future
time.
The X-Delete-At header requires a Unix Epoch timestamp, in integer form. For example,
1348691905 represents Wed, 26 Sep 2012 20:38:25 GMT. By setting the header to a specific
Epoch time, you indicate when you want the object to expire, not be served, and be
deleted completely from the storage system.
The X-Delete-After header takes an integer number of seconds that represents the
amount of time from now that you want the object to be deleted. The proxy server that
receives the request converts this header into an X-Delete-At header and calculates the
deletion time using its current time plus the value given in seconds.
For existing objects that you want to assign expiration headers to, use the POST operation.
Example 8.12. X-Delete-At Request
PUT /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/MyContainer/MyObject
HTTP/1.1
Host: storage.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
Content-Type: image/jpeg
X-Delete-At: 1339429105
Example 8.13. X-Delete-After Request
PUT /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/MyContainer/MyObject
HTTP/1.1
Host: storage.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
Content-Type: image/jpeg
X-Delete-After: 864000
8.6. Object Versioning
Object versioning allows you to store multiple versions of your content to recover from
unintended overwrites and deletions. It provides an easy method to implement version
control which can be used on any type of content. Rackspace strongly recommends that
you put non-current objects in a separate container from where the current versions exist.
Once you enable object versioning, new data written to an object causes the last-current
version to be written to the separate container. Each of the non-current versions has a
timestamp appended to it, so you know when it was originally created.
79
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
To enable object versioning, create a container where your non-current versions will be
written. Next, set the metadata X-Versions-Location header on the container that
holds the current versions of your objects. Set the metadata header to point to the new
non-current version container that you created. This is where your non-current versions will
be stored. Once this is done, each object in your current-version container will have object
versioning enabled. Changes to the objects automatically create non-current versions in the
separate container.
Nothing is written to the non-current version container when you initially PUT an object
into the current-version container. Only when you make edits to the objects with a PUT
request will you create non-current versions. These non-current versions are labeled
according to the schema below.
Any return status in the 2xx range, such as 202 (Accepted), denotes success. Status codes
in the 4xx or 5xx range denote failure. You should retry your request if you receive an
error. Note, however, that if you have specified a container that does not exist as your non-
current version container, a status of 412 (Precondition Failed) returns when you edit the
versioned object. If you receive this error, check to see if the container exists.
A GET to a versioned object returns the current version of the object without having to do
any request redirects or metadata lookups.
A POST to a versioned object only updates the object's metadata. It does not create a new
version of the object. In other words, new versions are only created when the content of
the object changes.
A DELETE to a versioned object removes the current version of the object and replaces it
with the next-most current version, moving it from the non-current container to the current
container. This next-most current version carries with it any metadata last set on it. If want
to completely remove an object and you have five total versions of it, you must DELETE it
five times.
Note
A large-object manifest file cannot be versioned, but it can point to versioned
segments.
To turn off object versioning on your current version container, remove its X-Versions-
Location metadata by sending a key value that is an empty string.
Make sure a version-storing container exists by creating it if necessary. This example names
it versions. Then create a container with the X-Versions-Location header. In
this example, this container is named current. You can also add the X-Versions-
Location header to an existing container. In this example, the name of the container is
versions. The location for the current version is the container current.
80
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
5. See a listing of the older versions of the object. (The example includes the hex number
for the length of the filename.)
curl -i -H "X-Auth-Token: yourAuthToken" \
http://yourStorageUrl/versions?prefix=008myobject/
6. Now delete the current version of the object and see that the older version is gone.
81
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
You direct the REST API methods described to the endpoints described in the
cloudFilesCDN section of the service catalog that you obtain during successful
authentication. (For more information, see Section 3.1, “Authentication” [10] and
Section 3.3, “Service Access Endpoints” [20].)
The following sections describe the operations that you can perform within the storage
system:
• Chapter 9, “API Operations for CDN Services” [82] describes operations that you can
perform at the account level for Cloud Files CDN services.
• Section 9.2, “CDN Container Services” [84] describes operations that you can perform
on containers.
• Section 9.3, “CDN Object Services” [93] describes operations that you can perform on
objects.
For your own requests, you must use your own account information and authentication
token. You can check how to generate an authentication token in Section 3.1.2,
“Retrieving the Authentication Token” [10]. Your authentication token and your account
information are in the service catalog that is produced.
82
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
GET operations against the cloudFilesCDN endpoints for an account retrieve a list
of CDN-enabled containers. (For the CDN endpoints, see Section 3.3, “Service Access
Endpoints” [20].)
The list of CDN-enabled containers is returned in the response body, one container name
per line.
A list of containers is returned in the response body, one container per line.
The HTTP response status code is a value from 200 to 299, inclusive. A 200 (OK) code
returns if there are containers, and a 204 (No Content) code returns if there are no
containers.
To view the CDN container details, see Section 9.2.2, “List a CDN-Enabled Container's
Metadata” [89].
9.1.1.1. Request
This table shows the URI parameters for the List CDN-Enabled Containers Request:
This table shows the Query parameters for the List CDN-Enabled Containers Request:
(Optional)
limit Int For an integer value n, limits the number of results to n values.
(Optional)
marker String Given a string value x, returns container names greater in value than
the specified marker. Only strings using UTF-8 encoding are valid.
(Optional) Using marker provides a mechanism to iterate through the entire list
of containers.
end_marker String Given a string value x, returns container names less in value than the
specified end marker. Only strings using UTF-8 encoding are valid.
(Optional)
format String Value of the serialized response format - either json or xml.
(Optional)
83
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
9.1.1.2. Response
Example 9.2. CDN-Enabled Containers List Response
HTTP/1.1 200 OK
Date: Thu, 08 Sep 2011 14:35:45 GMT
Transfer-Encoding: chunked
Content-Type: text/plain
images
movies
When you CDN-enable a container, all the objects within it become available on the CDN.
Similarly, once a container is CDN-enabled, any objects added to it through the storage
service become CDN-enabled. After you CDN-enable a container, its publicly-available URI
can be found with the header X-Cdn-Uri, and its objects may be accessed at X-Cdn-
Uri/objectName. By knowing this pattern, you can pre-generate the URI for an object
before it is added to the container.
When you enable a container in the CDN service, you automatically generate URIs for
SSL and streaming usage. They are listed under the X-Cdn-Ssl-Uri and X-Cdn-
Streaming-Uri headers, respectively.
On August 13, 2012, the format of new CDN URIs changed in order to enhance
the security of the Content Delivery Network. Any URIs set in the older
format (http://c25810.r10.cf1.rackcdn.com/mydog.jpg) continue
to work. However, any newly generated CDN URIs have the new format:
http://80745c48926cd286a5a0-48261ebe0e4c795a565ece6b9cca2fe8.
r10.cf1.rackcdn.com/mydog.jpg.
84
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
For your own requests, you must use your own account information, authentication
token, and container name. You can check how to generate an authentication token in
Section 3.1.2, “Retrieving the Authentication Token” [10]. Your authentication token and
your account information are in the service catalog that is produced.
85
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Before a container can be CDN-enabled, it must exist in the storage system. To CDN-enable
the container, perform a PUT request against it using the publicURL noted in the service
catalog for Cloud Files during Authentication and set the X-CDN-Enabled header to
True.
When a container is CDN-enabled, any objects stored in it are publicly accessible over the
content delivery network by combining the container's CDN URI with the object name (X-
Cdn-Uri/objectName ).
Note
The examples in this guide use cdn.clouddrive.com for an endpoint
for operations against the CDN management service, but you should use
whatever your authentication request provides. For more information about
your authentication request, see Section 3.1, “Authentication” [10]. For more
information about service access endpoints, see Section 3.3, “Service Access
Endpoints” [20].
Any CDN-accessed objects are cached in the CDN for a specified amount of time called the
Time To Live (TTL). Each time the object is accessed after the TTL expires, the CDN refetches
and caches the object for the next TTL period.
You can specify the TTL for an object by including the HTTP header X-TTL:
integerSeconds . Setting the TTL is the same as setting the HTTP Expires and
Cache-Control headers for the cached object. The minimum TTL is 15 minutes (900
seconds), and the maximum is 50 years for a range of 900 to 1576800000 seconds.
However, setting a TTL for a long time does not guarantee that the content stays
populated on CDN edge servers for the entire period. The most popular objects stay cached
based on the edge location's logic.
Note
On August 13, 2012, the maximum TTL was set to 31536000 (one year). If you
set new TTL values to a greater time frame, your object still expires at the one-
year mark. However, if you already had a greater TTL value set on an object, it
will expire at the time you originally set.
A status code of 201 (Created) indicates that the container was CDN-enabled as requested.
If the container is already CDN-enabled, a 202 (Accepted) status code is returned, and
the TTL is adjusted. A status code of 204 (No Content) indicates the container was CDN-
enabled as requested, but has no content.
This operation does not require a request body and does not return a response body.
86
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
In order to remove the container from the CDN, change the X-Cdn-Enabled header
to False, as in the request below. However, note that objects remain on the CDN edge
server and are served to the public until their TTL expires.
Note
The CDN URI is unique per container. After the container is CDN-enabled, you
can make a HEAD request to the Cloud Files CDN endpoint with the container
name to return the CDN URI in the X-Cdn-Uri header. You can use a cURL
request similar to the following example:
curl -I -H 'x-auth-token: yourAuthToken'
cloudFilesCDN:yourPublicURL/yourContainerName
9.2.1.1. Request
This table shows the Header parameters for the CDN-Enable and CDN-Disable a Container
Request:
(Optional)
This table shows the URI parameters for the CDN-Enable and CDN-Disable a Container
Request:
9.2.1.2. Response
This table shows the Header parameters for the CDN-Enable and CDN-Disable a Container
Response:
87
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
88
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
If the container is (or ever has been) CDN-enabled, the metadata is returned in headers in
the response for plain text, or in the response body for XML or JSON, if you request either
as your output format.
Note
Remember that your HEAD operation must be on the CDN host (i.e.,
cdn.clouddrive.com). Otherwise, you will see the metadata for your
private container as described in Section 5.1.3, “Get Account Metadata” [34].
A 204 (No Content) HTTP status code is returned if the account has no containers.
Otherwise, status code of 200 (OK) is returned.
9.2.2.1. Request
This table shows the URI parameters for the List a CDN-Enabled Container's Metadata
Request:
This table shows the Query parameters for the List a CDN-Enabled Container's Metadata
Request:
(Optional)
89
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Host: cdn.clouddrive.com
X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c
9.2.2.2. Response
This table shows the Header parameters for the List a CDN-Enabled Container's Metadata
Response:
(Required)
90
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
91
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
• X-Log-Retention
• X-Cdn-Enabled
• X-Ttl
A status code of 204 (No Content) indicates success. Status code 404 (Not Found) is
returned if the requested container is not found.
This operation does not require a request body and does not return a response body.
9.2.3.1. Request
This table shows the Header parameters for the Update CDN-Enabled Container Metadata
Request:
This table shows the URI parameters for the Update CDN-Enabled Container Metadata
Request:
92
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
9.2.3.2. Response
Example 9.13. Update CDN-Enabled Container Metadata Response
HTTP/1.1 204 No Content
X-Cdn-Ssl-Uri: https://83c49b9a2f7ad18250b3-346eb45fd42c58ca13011d659bfc1ac1.
ssl.cf0.rackcdn.com
X-Ttl: 259200
X-Cdn-Uri: http://081e40d3ee1cec5f77bf-346eb45fd42c58ca13011d659bfc1ac1.r49.
cf0.rackcdn.com
X-Cdn-Enabled: True
X-Log-Retention: False
X-Cdn-Streaming-Uri: http://
084cc2790632ccee0a12-346eb45fd42c58ca13011d659bfc1ac1.r49.stream.cf0.rackcdn.
com
X-Trans-Id: tx82a6752e00424edb9c46fa2573132e2c
Content-Length: 0
For your own requests, you must use your own account information, authentication token,
container name, and object name. You can check how to generate an authentication token
in Section 3.1.2, “Retrieving the Authentication Token” [10]. Your authentication token
and your account information are in the service catalog that is produced.
93
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
When you find it necessary to remove a CDN-enabled object from public access before the
TTL expires, you can perform a DELETE operation against the object, or you can create a
support ticket to purge the entire container.
Note
You should limit object purges to situations where there could be serious
personal, business, or security consequences if it remained publicly accessible
on the CDN (for example, when someone publishs your company's quarterly
earnings too early).
Following are the ways you can purge objects from the CDN:
You can manually purge CDN-enabled objects without having to wait for the TTL to
expire, and you can optionally be notified by email that the object has been purged.
However, you can only DELETE up to 25 objects per day using the API.
An attempt to delete more objects results in a 400 (Bad Request) status code with X-
Purge-Failed-Reason: You have the maximum number of daily object
purges.
If there is already a purge request in progress for an object, a 400 (Bad Request) status
code is returned with X-Purge-Failed-Reason: That object is already in
the queue to be purged.
The 25-object limit does not apply when purging an entire container through Support.
Note
To prevent the container from going back to the CDN, first change the X-CDN-
Enabled flag to False as shown in Section 9.2.1, “CDN-Enable and CDN-
Disable a Container” [86]
The system purges the object from the CDN and sends an email to the indicated address or
addresses. If you want to notify more than one person about the deletion, you can enter a
comma-separated list of addresses. The email address is optional.
A status code of 204 (No Content) indicates success. Status code 404 (Not Found) indicates
that requested CDN-enabled object was not found. Status code 403 (Forbidden) indicates
that an authorization problem occurred.
94
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Purging objects may take a long time because there are so many edge servers around the
globe. Please be patient while waiting for a response.
9.3.1.1. Request
This table shows the URI parameters for the Delete CDN Object Request:
9.3.1.2. Response
Example 9.15. Delete CDN-Enabled Object Response
HTTP/1.1 204 No Content
Date: Thu, 13 Jan 2010 18:57:07 GMT
X-Cdn-Uri: http://081e40d3ee1cec5f77bf-346eb45fd42c58ca13011d659bfc1ac1.r49.
cf0.rackcdn.com
Content-Length: 0
Content-Type: text/plain; charset=UTF-8
95
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Note
To prevent the container from going back to the CDN, first change the X-CDN-
Enabled flag to False as shown in Section 9.2.1, “CDN-Enable and CDN-
Disable a Container” [86].
A status code of 204 (No Content) indicates success. Status code 404 (Not Found) is
returned if the requested container was not found. No content is returned.
96
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
• X-Cdn-Streaming-Uri: specifies a URI for video streaming that uses Adobe’s HTTP
Dynamic Streaming
• X-Cdn-Ios-Uri: specifies the URI for video streaming that uses Apple’s HTTP Live
Streaming (see Section 10.4, “iOS Streaming” [97])
Streaming is a method of relaying data, such as video and audio material, over the network
as a steady continuous stream, allowing playback to proceed while subsequent data is
being received.
A status code of 204 (No Content) indicates success. Status code 404 (Not Found) is
returned if the requested container was not found. No content is returned.
For information about streaming to iOS devices, see Section 10.4, “iOS Streaming” [97].
10.4. iOS Streaming
The Cloud Files CDN allows you to stream video to iOS devices without needing to convert
your video. Once you CDN-enable your container, you have the tools necessary for
97
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
streaming media to multiple devices. To leverage this ability, you must check the client's
User Agent with JavaScript. An example of the User Agent check and how to use it is given
below.
First, CDN-enable your container. For instructions, see Section 9.2.1: “CDN-Enable and CDN-
Disable a Container”. Two streaming URIs are created - the container's streaming URI (X-
Cdn-Streaming-Uri) and its iOS streaming URI (X-Cdn-Ios-Uri). Perform a HEAD
request against the CDN-enabled container to view these URIs.
Second, link to your content in a HTML page using a <video> element. Set the SRC
attribute of the VIDEO element to the full streaming URI for your container plus the name
of your content. In the below example, the streaming video is MobyDick.mp4.
Third, add JavaScript to the <head> element of your HTML page to check if the User Agent
is an iOS device. If it is, the JavaScript should use the container's iOS streaming URI (x-Cdn-
Ios-Uri) instead of the regular streaming URI. The Cloud Files CDN delivers the properly
formatted content for iOS devices only when the iOS streaming URI is used. Here, the
JavaScript sets the SRC attribute of the <video> element videotag to the iOS Streaming
URI. Remember to add your content's name to the end of the iOS streaming URI.
function isIOS(){
return ((navigator.userAgent.match(/iPhone/i)) ||(navigator.userAgent.
match(/iPod/i)) || (navigator.userAgent.match(/iPad/
i))) != null;
}
function init(){
if (isIOS()){
document.getElementById(“videotag”).src = “http://
084cc2790632ccee0a12-346eb45fd42c58ca13011d659bfc1ac1.
iosr.cf0.rackcdn.com/MobyDick.mp4”;
}
}
</script>
Finally, add init() to the <body> element of your HTML page to call the User Agent
check when the page loads.
With these pieces of code in place, the proper content streams will be set for iOS devices.
98
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
The page you set for X-Container-Meta-Web-Index becomes the index page for every
subdirectory in your website. Each of your pseudo directories should contain a file with
that name. So, if you set X-Container-Meta-Web-Index to index.html, you should
have an index.html page in each pseudo directory. For example, suppose that you have
a subdir pseudo directory. If you do not have an index.html page in subdir, visits to
myhost/subdir/ return a status code 404 (Not Found).
You also have the option of displaying a list of HTML files in your pseudo directory,
instead of a web page. You do this by setting the X-Container-Meta-Web-Listings
header to True. If listings are enabled, you can add styles to your file list by setting X-
Container-Meta-Web-Listings-CSS to a style sheet. For example, setting X-
Container-Meta-Web-Listings-CSS: listing.css makes listings link to the
listing.css style sheet. To view the HTML elements to which you can add styles, use your
browser to view the HTML source on the listing page.
You can modify the Content-Type of directory marker objects by setting the
X-Container-Meta-Web-Directory-Type header. If this header is not set,
application/directory is used by default. Directory marker objects are 0-byte objects
that represent directories to create a simulated hierarchical structure.
The instructions below describe using a CNAME with your DNS Server (or name server). This
is the domain name of your site (such as www.rackspace.com). Your CNAME is set up with
your individual DNS Server. For more information about using CNAMES, see the Cloud DNS
Developer Guide at docs.rackspace.com. Once you have your CNAME established, set the
CNAME to your Cloud Files CDN URI to get your site up and running on the Web.
The following list gives the step-by-step instructions for setting up a Static Website.
1. Create a container.
99
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
3. Set the index (or primary page) for your website by performing a POST to the header
X-Container-Meta-Web-Index on your website's container. See the example
below. (Remember to change the X-Auth-Token to your authentication token.) You
must use your storage URL and the container name to properly point to the container
(storageURL/containerName).
(You get your Auth token when you authenticate your session as shown in Section 3.1:
“Authentication”.)
5. Go to your domain host and set up a CNAME using your CDN URI (X-Cdn-Uri).
The CNAME is the domain or branded URI you use instead of the CDN URI. If you
need to find your CDN URI, perform a HEAD to cdn.clouddrive.com as shown in
Section 9.2.2: “List a CDN-Enabled Container's Metadata”.
6. To view your website online, visit your CDN URI or your CNAME domain.
After your container has an index page set and your domain host has your CNAME
recorded, your static website is ready.
Error pages are served with the status code prepended to the name of the error page you
set. For instance, if you set X-Container-Meta-Web-Error to error.html, 401 errors
100
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
display the page 401error.html. Similarly, 404 errors display 404error.html. You
must have both of these pages created in your container when you set the X-Container-
Meta-Web-Error metadata, or your site will display generic error pages.
Set the X-Container-Meta-Web-Error metadata once for your entire static website.
101
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Note
Bulk import is available for U.S. data centers only. However, if you have a need
for bulk importing in a data center outside of the U.S., contact Rackspace
support to see what other options you might have. They will be interested in
specifics like the amount of data you need to work with.
Rackspace accepts USB, SATA, and eSATA devices. Your file system can be NTFS, ext2,
ext3, ext4, or FAT32. Because Cloud Files does not use hierarchical directory structures,
nested sub-directories in your data are converted to object names. Your top-level folders
become containers, and nested directory names become part of the object names. For
instance, Chapter28/Ahab/ivoryleg results in a container named Chapter28 with an
object named Ahab/ivoryleg inside of it. For more information on simulating directory
structures in Cloud Files, see Chapter 6, “Pseudo Hierarchical Folders and Directories” [66].
To begin the bulk import process, contact Rackspace support technicians. You will be
assigned a migration specialist who can answer any questions you might have along the
way. You are notified when Rackspace receives your device, begins the data import,
completes data import, and ships back or destroys the device.
12.2. Extract Archive
An extract archive request expands tar files into a Cloud Files account. The request is a PUT
with the query parameter ?extract-archive=format specifying the format of archive
file. Accepted formats are tar, tar.gz, and tar.bz2.
Note
The bulk operation involves middleware that conducts many operations on a
single request.
/v1/AUTH_Account/$UPLOAD_PATH?extract-archive=tar.gz
UPLOAD_PATH is the location where the files are expanded and can specify any of the
following:
102
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
• a container
• an empty string
/v1/AUTH_Account/$UPLOAD_PATH/$FILE_PATH
FILE_PATH is the file name from the listing in the tar file.
You can create up to 1,000 new containers per extraction request. Also note that
only regular files are uploaded. Objects such as empty directories and symlinks are not
uploaded.
The responses from bulk operations are not like other Cloud Files responses because a
short request body sent from the client could result in many operations on the proxy server
and precautions need to be made to prevent the request from timing out due to a lack of
activity. To this end, the client always receives a 200 OK response, regardless of the actual
success of the call. The body of the response, which can be delivered over a greater amount
of time, must be parsed to determine the actual success of the operation. In addition, the
client may receive whitespace characters prepended to the response body while the proxy
server is completing the request.
The format of the response body defaults to text plain but can be either JSON or XML
depending on the Accept header. Acceptable formats are text/plain, application/
json, application/xml, and text/xml. The following example shows the response
body, formatted in JSON, from a successful request.
HTTP/1.1 200 OK
Content-Type: application/json
X-Trans-Id: txa7fd1603cfe04bdb920cd-005191226d
Date: Mon, 13 May 2013 17:27:10 GMT
Transfer-Encoding: chunked
{
"Number Files Created": 10,
"Response Status": "201 Created",
"Errors": [],
"Response Body": ""
}
103
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
HTTP/1.1 200 OK
Content-Type: application/json
X-Trans-Id: tx9f12e16f047049cc91147-005191245f
Date: Mon, 13 May 2013 17:35:27 GMT
Transfer-Encoding: chunked
{
"Number Files Created": 10,
"Response Status": "400 Bad Request",
"Errors": [
[
"/v1/AUTH_test/test_cont/big_file.wav",
"413 Request Entity Too Large"
]
],
"Response Body": ""
}
If all valid files were uploaded successfully, the Response Status in the response body is
201 Created. If any files failed to be created, the Response Status corresponds to the
subrequest's error. Possible codes are 400, 401, and 502. In both cases, the response body
specifies the number of files successfully uploaded and a list of the files that failed. (The
actual HTTP status code is always 200 OK, so the response code in the response body is the
one you should monitor.)
Note
If you send a Content-Type on the PUT request, the specified Content-
Type applies to every object in the archive. If you set Content-Type to
a blank string, Cloud Files determines the Content-Type based on the
individual file type. For example, if you have MIME type files, use a blank string
for Content-Type to set the MIME type for files within the archive.
12.3. Bulk Delete
Bulk Delete request deletes multiple objects or containers from an account with a single
request. A Bulk Delete request is a DELETE request with the query parameter ?bulk-
delete set. The Content-Type header of the request, if set, must be set to text/
plain. You should direct the request to the service endpoints in Section 3.3, “Service
Access Endpoints” [20]. The requests should be directed to the root of the service endpoint.
The body of the DELETE request a newline-separated list of URL-encoded objects to delete.
You can delete 10,000 objects per request.
Note
The bulk operation involves middleware that conducts many operations on a
single request.
The objects specified in the DELETE request body must be URL-encoded and in the form:
104
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
/containerName/objectName
/containerName
The response is similar to the extract archive responses in that every response will be 200
OK and the response body must be parsed for actual results. The following example shows
the response body, formatted in JSON, from a successful request.
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
X-Trans-Id: tx52fe4601dde24e2b8e7cb-0051912ca8
Date: Mon, 13 May 2013 18:10:48 GMT
Transfer-Encoding: chunked
{
"Number Not Found": 1,
"Response Status": "200 OK",
"Errors": [],
"Number Deleted": 10,
"Response Body": ""
}
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
X-Trans-Id: tx28552a8cd9cb441dad3ad-0051912d2d
Date: Mon, 13 May 2013 18:13:01 GMT
Transfer-Encoding: chunked
{
"Number Not Found": 0,
"Response Status": "400 Bad Request",
"Errors": [
[
"/v1/AUTH_test/non_empty_container",
"409 Conflict"
]
],
"Number Deleted": 0,
"Response Body": ""
}
If all items were successfully deleted (or did not exist), the status code is 200 OK. If any
failed to delete, the status code corresponds to the subrequest's error. Possible codes
are 400, 401, and 502. In all cases, the Response Body specifies the number of items
successfully deleted or not found as well as a list of those that failed. The return body is
105
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
formatted in the way specified in the request's Accept header. Acceptable formats are
text/plain, application/json, application/xml, and text/xml.
The list of errors is a list of tuples in the form [objectPath, errorResponse]. The
objectRath is the full path of where the object (or container) was to be deleted. The
errorResponse is the failing HTTP status of the response for that individual DELETE.
106
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
13.1. TempURL
The Temporary URL feature (TempURL) allows you to create limited-time Internet
addresses that allow you to grant limited access to your Cloud Files account. Using
TempURL, you can allow others to retrieve or place objects in your Cloud Files account for
a specified amount of time. Access to the TempURL is independent of whether or not your
account is CDN-enabled. And even if you do not CDN-enable a directory, you can still grant
temporary public access through a TempURL.
This feature is useful if you want to allow a limited audience to download a file from your
Cloud Files account or website. You provide a TempURL and after a specified time, no one
will be able to access that object using the TempURL. Or, if you want to allow others to
upload objects into your Cloud Files account, you can give them a TempURL. After the
specified time expires, no one will be able to upload to the address.
Additionally, you need not worry about time running out when someone downloads a
large object. If the time expires while a file is being retrieved, the download will continue
until it is finished. Only the link will expire.
When you create a TempURL, Cloud Files validates a GET-accessible or PUT-accessible URL,
which is time-limited.
Note
The TempURL is the same thing as TempURL Secret, and is set using the
TempURL metadata key described in the next section. The TempURL is the
actual URL.
Once the key is set, you should not change it while you still want others to be able to access
your TempURL. If you change it, the TempURL becomes invalid (within 60 seconds, which is
the cache time for a key) and others will not be allowed to access it.
107
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
In the following examples, a TempURL is generated for the object my_cat.jpg that will be
available for 60 seconds. The key in the example below is the X-Account-Meta-Temp-
Url-Key.
import hmac
from hashlib import sha1
from sys import argv
from time import time
if len(argv) != 5:
print 'Syntax: <method> <url> <seconds> <key>'
print 'Example: GET https://storage101.dfw1.clouddrive.com/v1/' \
'MossoCloudFS_12345678-9abc-def0-1234-56789abcdef0/' \
'container/my_cat.jpg 60 my_shared_secret_key'
else:
method, url, seconds, key = argv[1:]
method = method.upper()
base_url, object_path = url.split('/v1/')
object_path = '/v1/' + object_path
seconds = int(seconds)
expires = int(time() + seconds)
hmac_body = '%s\n%s\n%s' % (method, expires, object_path)
sig = hmac.new(key, hmac_body, sha1).hexdigest()
print '%s%s?temp_url_sig=%sAMP;temp_url_expires=%s' % \
(base_url, object_path, sig, expires)
Be certain to use the full URL to the object, just as you would with a normal request.
https://storage.clouddrive.com/v1/AUTH_account/container/my_cat.jpg?
temp_url_sig=da39a3ee5e6b4b0d3255bfef95601890afd80709&
temp_url_expires=1323479485
If you do not provide users with the exact TempURL, they get a 401 (Unauthorized) status
code. HEAD queries are allowed if GET or PUT are allowed.
108
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
<?php
if ($argc != 5) {
echo "Syntax: <method> <url> <seconds> <key>";
echo "Example: GET https://storage101.dfw1.clouddrive.com/v1/" .
"MossoCloudFS_12345678-9abc-def0-1234-56789abcdef0/" .
"container/my_cat.jpg 60 my_shared_secret_key";
} else {
$method = $argv[1];
$url = $argv[2];
$seconds = $argv[3];
$key = $argv[4];
$method = strtoupper($method);
list($base_url, $object_path) = split("/v1/", $url);
$object_path = "/v1/$object_path";
$seconds = (int)$seconds;
$expires = (int)(time() + $seconds);
$hmac_body = "$method\n$expires\n$object_path";
$sig = hash_hmac("sha1", $hmac_body, $key);
echo "$base_url$object_path?" .
"temp_url_sig=$sig&temp_url_expires=$expires";
}
?>
require "openssl"
unless ARGV.length == 4
puts "Syntax: <method> <url> <seconds> <key>"
puts ("Example: GET https://storage101.dfw1.clouddrive.com/v1/" +
"MossoCloudFS_12345678-9abc-def0-1234-56789abcdef0/" +
"container/path/to/object.file 60 my_shared_secret_key")
else
method, url, seconds, key = ARGV
method = method.upcase
base_url, object_path = url.split(/\/v1\//)
object_path = '/v1/' + object_path
seconds = seconds.to_i
expires = (Time.now + seconds).to_i
hmac_body = "#{method}\n#{expires}\n#{object_path}"
sig = OpenSSL::HMAC.hexdigest("sha1", key, hmac_body)
puts ("#{base_url}#{object_path}?" +
"temp_url_sig=#{sig}&temp_url_expires=#{expires}")
end
109
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
https://cf-cluster.example.com/v1/AUTH_account/container/object?temp_url_sig=
da39a3ee5e6b4b0d3255bfef95601890afd80709&temp_url_expires=1323479485
https://cf-cluster.example.com/v1/AUTH_account/container/object?temp_url_sig=
da39a3ee5e6b4b0d3255bfef95601890afd80709&temp_url_expires=1323479485&filename=
bob.txt
13.2. FormPost
FormPost lets you offer your website audience a way to upload objects to your Cloud Files
account through a web form. FormPost works by translating a browser form request into a
object PUT in Cloud Files. Once you enable FormPost on your account, you need only create
the form in your website using the guidelines below.
As with all objects in Cloud Files, the object file size limit is 5 GB. If your users try to upload
an object larger than 5 GB, they will get a file size error.
Once the key is set, you cannot change it while you still want others to access your account.
If you change it, the actions from a FormPost become invalid (within 60 seconds, which is
the cache time for a key).
110
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Required: Form action is the Cloud Files URL (CF-url) to the destination where files will
be uploaded. For instance, https://storage.clouddrive.com/v1/CF_xer7_34/
container. The name of each uploaded object will have the <CF-url> appended to the
front of it.
Note
You can also include a prefix to separate uploads, such as assigning each user
a certain prefix: https://storage.clouddrive.com/v1/CF_xer7_34/
container/user_prefix.
Required: The form method must be POST and the enctype must be set as multipart/
form-data.
Optional: The redirect attribute is the URL of the page that displays on your website
after the form processes. The URL will have status and message query parameters added
to it, indicating the HTTP status code for the upload (2xx indicates success) and a possible
message for further information if there is an error, such as “max_file_size exceeded”.
Note
Although redirect is optional for the form, it must be present in the HMAC
body.
Required: The max_file_size attribute must be included and specifies the maximum
size in bytes of a single file. However, the storage system maximum file size is 5 GB, so
max_file_size cannot exceed 5 GB.
Required: The max_file_count attribute indicates the maximum number of files that can
be uploaded with the form.
Required: The expires attribute is the Unix timestamp when the form is invalidated. This
gives your website users a limited time to have the form open. Time must be in Unix epoch
format.
Note
expires in the web form and expires in the HMAC must be the same.
Required: The signature attribute is the HMAC-SHA1 signature of the form. Here is
sample code for computing the signature in Python:
111
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
import hmac
from hashlib import sha1
from time import time
path = '/v1/account/container/object_prefix'
redirect = 'https://myserver.com/some-page'
max_file_size = 104857600
max_file_count = 10
expires = int(time() + 600)
key = 'mykey'
hmac_body = '%s\n%s\n%s\n%s\n%s' % (path, redirect,
max_file_size, max_file_count, expires)
signature = hmac.new(key, hmac_body, sha1).hexdigest()
Be certain to use the full path in your Cloud Files account, from the /v1/ onward.
The redirect value can be an empty string to indicate that no redirect is included on the
form.
The key value is the value of the X-Account-Meta-Temp-Url-Key header set for the
account.
The max_file_count value used to generate the signature must be the same as that
in the web form.
Required: The type="file" field defines the form file field. At least one entry is required
to allow your users to select and upload a file, but additional fields may be added for
multiple files. The number of entries should not, however, exceed the max_file_count.
Each type="file" field must have a different name.
Note
The type="file" field(s) must be at the end of the form code in order for
Cloud Files to process the uploads properly.
13.3. CORS
Cross-Origin Resource Sharing (CORS) is a mechanism to allow code running in a browser to
make requests to a domain other than the one from which it originated. CORS container
headers allow your users to upload files from one website, or origin, to your Cloud Files
account. When you set the CORS headers on your container, you provide Cloud Files with
the following information:
Note
You use CORS with:
112
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
• TempURL (Section 13.1: “TempURL ”) to limit how long users can use a given
URL
Cloud Files supports CORS requests to containers and objects. CORS metadata is held on the
container only. The values given apply to the container itself and all objects within it.
Before a browser issues an actual request, it might issue a preflight request. The preflight
request is an HTTP OPTIONS call to verify that the origin is allowed to make the request.
The sequence of events is:
2. Cloud Files returns 200 or 401 to the browser based on the allowed origins.
3. If Cloud Files returns 200, the browser makes the actual request (DELETE, GET, HEAD,
POST, PUT) to Cloud Files.
When a browser receives a response to an actual request, it only exposes those headers
listed in the X-Container-Meta-Access-Control-Expose-Headers header. By
default, Cloud Files returns the following values for this header:
2. Host the page on a web server and take note of the protocol and hostname (origin) you
will be using to request the page, for example http://localhost.
3. Locate a container you would like to query. (Of course, the Cloud Files cluster hosting
this container should have CORS support.)
113
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
2. Populate the URL filed with the URL of either a container or object.
4. Hit Submit.
If the request succeeds, you should see the response header and body. If the request did
not succeed, the response status will be 0.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test CORS</title>
</head>
<body>
Method<br>
<select id="method">
<option value="GET">GET</option>
<option value="HEAD">HEAD</option>
<option value="POST">POST</option>
<option value="DELETE">DELETE</option>
<option value="PUT">PUT</option>
</select><br><br>
<pre id="response_headers"></pre>
<p>
<hr>
<pre id="response_body"></pre>
<script type="text/javascript">
114
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
function submit() {
var token = document.getElementById('token').value;
var method = document.getElementById('method').value;
var url = document.getElementById('url').value;
document.getElementById('response_headers').textContent = null;
document.getElementById('response_body').textContent = null;
request.open(method, url);
request.setRequestHeader('X-Auth-Token', token);
request.send(null);
}
</script>
</body>
</html>
115
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Remember that object and container names must be URL-encoded and UTF-8 encoded.
Object names must be less than 1024 bytes in length after URL-encoding. For example, an
object name of C++final(v2).txt should be URL-encoded as C%2B%2Bfinal%28v2%29.txt
and therefore be 24 bytes in length rather than the expected 16.
Also, tokens expire after 24 hours. Be sure you request a new token programmatically only
when the one you have is expired.
14.1. Using cURL
cURL is a command-line tool that you can use to interact with REST interfaces. cURL lets
you to transmit and receive HTTP requests and responses from the command line or a shell
script, which enables you to work with the API directly (without using one of the language-
specific APIs). It is available for Linux® distributions, Mac OS X® , and Windows®. For more
information about cURL, see http://curl.haxx.se.
The following examples demonstrate how to use cURL to obtain the authorization token
and the URL of the storage system. Note that your account may be based in either the
US or the UK. This is not determined by your physical location, but by the location of the
Rackspace retail site where the account was created.
116
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
{
"access": {
"serviceCatalog": [
{
"endpoints": [
{
"publicURL": "https://cdn1.clouddrive.com/
v1/yourAccountId",
"region": "DFW",
…
},
...
],
"name": "cloudFilesCDN",
"type": "rax:object-cdn"
},
{
"endpoints": [
{
"internalURL": "https://snet-storage101.dfw1.
clouddrive.com/v1/yourAccountId",
"publicURL": "https://storage101.dfw1.clouddrive.com/
v1/yourAccountId",
"region": "DFW",
…
},
...
],
"name": "cloudFiles",
"type": "object-store"
},
...
],
"token": {
"RAX-AUTH:authenticatedBy": [
"APIKEY"
],
"expires": "2013-10-29T05:36:28.683-05:00",
"id": "<auth_token>",
},
...
}
}
The storage URL, CDN management URL, and authentication token are returned in the
response. After authentication, you can use cURL to perform GET, HEAD, DELETE, POST
and PUT requests on the storage and CDN services.
While an authentication token lasts, you can continue to perform requests. However, once
a token expires, it will return an HTTP status code 401 (Unauthorized). Given that a token is
good for 24 hours, even long-running jobs do not need to re-authenticate on every request.
You will not need to request another X-Auth-Token again until the existing one expires.
At that point, you must obtain another authorization token. As a best practice example,
here is some pseudo code for re-authenticating. The best scalable process flow would be:
117
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
2. Send requests to the Cloud Files service access endpoints and set the X-Auth-Token
header with the authentication token obtained in Step 1.
3. Repeat step 2 using the same authentication token retrieved in Step 1 until either the
job finishes or you get a result code of 401 (Unauthorized).
• If the job finishes, you can allow the token to expire with no further action.
A Python-based example of how to check for errors and re-authenticate upon receiving an
error can be found in the OpenStack Swift project in client.py, which is freely available.
curl -X HEAD -D - \
-H "X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c" \
https://storage.clouddrive.com/v1/CF_xer7_343
The HTTP request must include a header to specify the authentication token. The HTTP
headers in the response indicate the number of containers in this storage account and the
total bytes stored for the entire account.
curl -X PUT -D - \
-H "X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c" \
118
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
https://storage.clouddrive.com/v1/CF_xer7_343/images
Returning an HTTP status code of 201 (Created) indicates that the container was
successfully created.
Note
On August 13, 2012, the maximum TTL was set to 31536000 (one year). If
you set new TTL values to a greater time frame, your object will still expire at
119
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
the one-year mark. However, if you already had a greater TTL value set on an
object, it will expire at the time you had originally set.
curl -X PUT -D - \
-H "X-Auth-Token: f064c46a782c444cb4ba4b6434288f7c" \
-H "X-CDN-Enabled: True" \
-H "X-TTL: 259200" \
https://cdn.clouddrive.com/v1/CF_xer7_343/images
When the container is CDN-enabled, the service returns its public URL in the X-CDN-URI
header of the response, plus the SSL URL in the X-Cdn-Ssl-Uri header of the response.
Now you can combine this URL with the object name to access the file through the CDN, or
use the https:// URL in combination with the object name to access the file over a secure
SSL connection through the CDN.
You can verify the CDN's cache settings that you specified with your TTL value by sending
a GET request to the object's CDN URL and viewing the response headers. The TTL value
you specify translates to the Expires and Cache-Control headers of the CDN's cached
Object.
The cURL command below issues a GET request which downloads the entire file but writes
it to /dev/null, a data sink that will not actually save the content to your local drive (this
convention is only valid on UNIX-like systems).
curl -s -D - \
http://80745c48926cd286a5a0-48261ebe0e4c795a565ece6b9cca2fe8.r10.cf1.
rackcdn.com/wow1.jpg \
-O /dev/null
HTTP/1.1 200 OK
Date: Thu, 06 Aug 2009 01:40:12 GMT
Expires: Fri, 07 Aug 2009 01:40:12 GMT
120
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
It should be noted that generally each time curl is invoked to perform an operation,
a separate TCP/IP and SSL connection is created and thrown away. The language APIs,
however, are designed to re-use these connections between operations and therefore
provide much better performance. We recommend that you use one of the language APIs
in your production applications and limit curl to quick-and-easy testing/troubleshooting.
121
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Glossary
Account
The Cloud Files system is designed to be used by many different customers. Your user account is
your slice of the Cloud Files system. You must identify yourself with a valid user name and your
API access key. Once authenticated, your have full read/write access to the objects (files) stored
under your account.
Authentication
Authentication requires getting an authentication token by using the Rackspace Cloud Identity
service. While the authentication token is valid (which in most cases is 24 hours), you must pass it
to Cloud Files to perform all Cloud Files operations.
CDN-enabled containers
To publish your data so that it can be served by Akamai's content delivery network (CDN), you
need to CDN-enabled the container that houses that data. When a container is CDN-enabled,
any files in the container are publicly accessible and do not require an authentication token for
read access. However, uploading content into a CDN-enabled container is a secure operation
and requires a valid authentication token. Each published container has a unique URL that
can be combined with its object name and openly distributed in web pages, emails, or other
applications. For example, a CDN-enabled container named photos can be referenced as
http://c0344252.cdn.cloudfiles.rackspacecloud.com. If that container houses an
image called cute_kids.jpg, that image can be served by Akamai's CDN with the full URL of
http://c0344252.cdn.cloudfiles.rackspacecloud.com/cute_kids.jpg.
Container
A storage compartment that provides a way for you to organize data. A container is similar to a
folder in Windows or a directory in UNIX. The primary difference between a container and these
other file system concepts is that containers cannot be nested.
Language-specific API
Language-specific APIs in several popular languages are available to help put Cloud Files in the
hands of developers. These APIs provide a layer of abstraction on top of the base REST API,
allowing programmers to work with a container and object model instead of working directly
with HTTP requests and responses.
Middleware
Software that connects two otherwise separate applications. For example, there are a number of
middleware products that link a database system to a Web server.
122
Rackspace Cloud Files™ February 21, 2014 API v1
Developer Guide
Operations
Operations are the actions you perform against your account in Cloud Files, such as creating or
deleting containers, uploading or downloading objects, etc. Operations are performed via the
REST web service API or a language-specific API.
Permissions
There are no permissions or access-controls for containers or objects other than being split into
separate accounts. You must authenticate with a valid API access key, but once authenticated you
can create and delete containers and objects only within that account.
Private container
A private container is a container that is only accessible by the account holder.
Public container
A public container is a CDN-enabled container that is publicly accessible.
REST
REST, short for Representational State Transfer, is an architectural style for large-scale software
design.
123