Last active
August 29, 2015 13:57
-
-
Save ycombinator/9391794 to your computer and use it in GitHub Desktop.
Pseudo-folders within container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use OpenCloud\Rackspace; | |
use OpenCloud\ObjectStore\Resource\DataObject; | |
// Create a client object to communicate with various Rackspace Cloud services. | |
$client = new Rackspace(Rackspace::UK_IDENTITY_ENDPOINT, array( | |
'username' => '<YOUR RACKSPACE CLOUD USERNAME HERE>', | |
'apiKey' => '<YOUR RACKSPACE CLOUD API KEY HERE>' | |
)); | |
$region = 'DFW'; | |
$objectStoreService = $client->objectStoreService('cloudFiles', $region); | |
// Create a container. | |
$container = $objectStoreService->createContainer('images'); | |
// Upload a file to the container. Note the nesting in the destination | |
// file name ($destFilename). This is what *simulates* a nested folder | |
// structure within the container. | |
$srcFilename = '/Users/me/Pictures/mugshot.png'; | |
$destFilename = 'photos/personal/me.png'; | |
$data = fopen($srcFilename, 'r+'); | |
$object = $container->uploadObject($destFilename, $data); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment