Skip to content

Instantly share code, notes, and snippets.

View ycombinator's full-sized avatar

Shaunak Kashyap ycombinator

  • Elastic
  • San Jose, CA
View GitHub Profile
@ycombinator
ycombinator / cloudfiles-skip-if-exists.php
Created March 6, 2014 17:33
How to check if a file exists in a Rackspace Cloud Files container
<?php
// Assumption: $container is an instance of OpenCloud\ObjectStore\Resource\Container
$filename = 'mugshot2.png';
try {
// Try to retrieve the file, but only its headers to save
// bandwidth and time.
@ycombinator
ycombinator / pseudo-folders-within-container.php
Last active August 29, 2015 13:57
Pseudo-folders within container
<?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>',
Content-Type: multipart/mixed; boundary=9021d370dd4927r43097g2
--9021d370dd4927r43097g2
Content-Type: application/json
<json data>
--9021d370dd4927r43097g2
Content-Type: application/xml