Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* A test vehicle to allow myself to learn the new RackSpace OpenCloud PHP SDK
*
*/
// include the Rackspace Cloud files PHP API
require 'rackspace_config.php';
require 'libraries/rackspace/vendor/autoload.php';
use OpenCloud\Rackspace;
@nickweavers
nickweavers / gist:9939652
Last active August 29, 2015 13:58
A Joomla model that gets a file from RackSpace's cloud
function getFile($id_file) {
$fileRecord = $this->getFileRecord($id_file);
$client = new Rackspace(Rackspace::UK_IDENTITY_ENDPOINT, array( // Note the use of
'username' => USER,
'apiKey' => PSWD
));
// Create a service object to use the object store service. We give it the region name on LON (For London) as this is where are server and cloud files are
@nickweavers
nickweavers / gist:9940340
Created April 2, 2014 18:38
A view/tmpl file to show send a files contents to the browser with appropriate headers
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
header("Cache- Control: no-cache, must-revalidate" ); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
$doc = $this->archivingModel->getFile($this->form_data['id_file']);
$file_type = $doc->content_type;
$content_body = $doc->content_body;
header("Content-Type: " . $file_type);