Question

I'm using the following CURL request to post a file to Rackspace Cloud Files:

$ch = curl_init(trim($rackspace['X-Storage-Url']).'/container/hello');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Auth-Token: '.$rackspace['X-Auth-Token'], 'Content-Length: '.$data['file']['size']));
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, fopen($data['file']['path'], 'r'));
curl_setopt($ch, CURLOPT_INFILESIZE, $data['file']['size']);
curl_setopt($ch, CURLOPT_HEADER, true);
echo curl_exec($ch);

I'm following the Rackspace documentation, but I'm getting a 404 Not Found error and I'm not quite sure how to troubleshoot this. Any suggestions?

SOLUTION

After further analysis, I discovered that the X-Storage-Url that was issued after authenticating was https://storage101.dfw1.clouddrive.com. The dfw1 indicates the data center in Dallas, but the containers I created were in Chicago. To confirm that this was the problem, I created a container at the Dallas data center and tried again – everything worked fine. I submitted a ticket to Rackspace to have my default storage location changed to Chicago. Everything is working now.

As pointed out in the selected answer, if I had been using the most up-to-date version of the API (2.0), then I would have been presented with URLs for both locations.

Was it helpful?

Solution

It sounds like you're using the old v1.0 authentication method as shown in the API docs here. Doing so will always return your default storage location. However, with v2.0 of the API auth system as described here, the authentication response will contain two different Cloud Files endpoint URLs, one for each data center. These both point to the same API, though, so all of your other Cloud Files-related code should "just work" if you swap out your authentication code.

OTHER TIPS

After further analysis, I discovered that the X-Storage-Url that was issued after authenticating was https://storage101.dfw1.clouddrive.com. The dfw1 indicates the data center in Dallas, but the containers I created were in Chicago. To confirm that this was the problem, I created a container at the Dallas data center and tried again – everything worked fine. I submitted a ticket to Rackspace to have my default storage location changed to Chicago. Everything is working now.

A container with the name "container" needs to already exist under your account in the region your X-Storage-Url points at. You're likely getting a 404 on the container, preventing the object from being created within it. You can create the container via a PUT to the API or through the control panel at http://mycloud.rackspace.com/.

-Mark

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top