This page will walk you through connecting to CloudFiles from your CloudServer. CloudServers have a special feature that will allow you to communicate directly with CloudFiles without being charged bandwidth. This is possible because of the internal IP address that your server comes with called a ServiceNet.
If you are not familiar with CloudFiles you might want to take a look at our product information located here: www.rackspace.com/cloud/cloud_hosting_products/files/
To view or download the API documentation please visit docs.rackspace.com/api/ and go to the Cloud Files section.
You can also access the documentation and some code samples from docs.rackspace.com/sdks/guide/content/intro.html or from within the First Gen Control Panel (manage.rackspacecloud.com) Cloud Control Panel by navigating to "Support" on the left and then "Developer Resources". We have code samples available for PHP, Python, and Java.
Cloud Servers can connect to Cloud Files, without bandwidth charges, when the Cloud Server and Cloud Files account are in the same data center. To accomplish this you must use the internal network host name. The host name will be the Cloud Files storage url with "snet-" pre-pended to it. Please keep in mind that you will still be charged for requests and storage.
You can locate your Cloud Server data center two ways:
To demonstrate how this can be accomplished, here's an example with the PHP API.
<?php
require("cloudfiles.php");
# Insert valid credentials
#
$auth = new CF_Authentication($USERNAME, $API_KEY);
# enable verbose output from curl and authenticate
#
$auth->setDebug(1);
$auth->authenticate();
# print out storage url (storage.clouddrive.com or storage4.clouddrive.com)
#
print $auth->storage_url . "\n";
# create the service net version (prepend 'snet-' to FQDN
#
$sn_url = "https://snet-" . substr($auth->storage_url, strlen("https://"));
print $sn_url . "\n";
# set the auth's storage url to the service net version
#
$auth->storage_url = $sn_url;
# grab a connection to the storage system via service net
#
$conn = new CF_Connection($auth);
$conn->setDebug(1);
print_r($conn->list_containers());
?>
Note that the code example is intended to illustrate building a ServiceNet storage URL, but some of the language bindings (including PHP) offer ways to specify ServiceNet connections instead of needing to build a full URL. So for that code example, it would be possible to remove the sections that create $sn_url and set it as the storage URL by changing the new connection line to:
$conn = new CF_Connection($auth, $servicenet=TRUE);
© 2011-2013 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

5 Comments
Looks like the API
http://www.rackspace.com/cloud/cloud_hosting_products/files/api/
Re: API
API
I discovered that we could used this method too:
<code>
$conn = new CF_Connection($auth, TRUE); //the boolean forces connection throughout ServiceNet
</code>
Re: Servicenet
Python servicenet
conn = cloudfiles.get_connection(username,api_key,servicenet=True)
Add new comment