
Rackspace Cloud Logo
You may have seen our previous blog post here for uploading files to Rackspace Cloud using the PHP API. Despite the relatively easy script it wasn’t plain sailing for us and we had to troubleshoot a number of errors. We wanted to share our fixes with you as we couldn’t find any resolutions on Google.
The first error we got was;
Fatal error: Uncaught exception 'InvalidResponseException' with message 'Unexpected response (): ' in /home/uname/public_html/rackspaceupload/cloudapi/cloudfiles.php:206 Stack trace: #0 /home/uname/public_html/rackspaceupload/upload.php(12): CF_Authentication->authenticate() #1 {main} thrown in /home/uname/public_html/rackspaceupload/cloudapi/cloudfiles.php on line 206
Now from the error message you would assume that it has something to do with your username or API key due to it mentioning the authentication function. Although if it was an issue with authentication you would probably see ‘AuthenticationException’ as the exception. In this case we found that Curl Open SSL was not installed despite having Curl installed. So ask your server administrator to install it for you if you receive this error.
Another big error we got was;
Fatal error: Uncaught exception 'BadContentTypeException' with message 'Required Content-Type not set' in /home/uname/public_html/rackspaceupload/cloudapi/cloudfiles.php:1645 Stack trace: #0 /home/uname/public_html/rackspaceupload/cloudapi/cloudfiles.php(1962): CF_Object->_guess_content_type('/tmp/phpyese5G') #1 /home/uname/public_html/rackspaceupload/upload.php(19): CF_Object->load_from_filename('/tmp/phpyese5G') #2 {main} thrown in /home/uname/public_html/rackspaceupload/cloudapi/cloudfiles.php on line 1645
This error took us a very long time to figure out, with some help from Rackspace Support we finally reached a resoltuion. We solved this by doing two things, first we installed the PECL Fileinfo Module, this module is to get file information, we the needed to install the PHP module ‘mod_mime_magic’. This then solved this issue and we can now upload to Rackspace Cloud.

Got another error? Having trouble resolving these errors? Fell free to leave a comment below and we will offer you any advice that we can.
We accept no responsibility for anything that happens to your server if you follow our advice, we are just supplying you with information on how we solved these issues.