Skip to content

Instantly share code, notes, and snippets.

@lorenzoaiello
Last active August 29, 2015 14:01
Show Gist options
  • Save lorenzoaiello/fb1427c6d65dde7502ed to your computer and use it in GitHub Desktop.
Save lorenzoaiello/fb1427c6d65dde7502ed to your computer and use it in GitHub Desktop.
Requires Softlayer ObjectStorage Client (https://github.com/softlayer/softlayer-object-storage-php)
<?php
/**
USAGE
php file.php CONTAINERNAME
NOTE
By Default Softlayer has a limit of 100 file return. To change it
$container = $objectStorage->with($argv[1])->get();
becomes
$container = $objectStorage->with($argv[1])->get(MAXFILELIMIT);
*/
require 'ObjectStorage.php';
require 'ObjectStorage/Util.php';
$options = array('adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 10);
$host = 'https://DCENDPOINT.objectstorage.softlayer.net';
$username = 'SL1234-0:1234';
$password = 'yourapikeyhere';
$objectStorage = new ObjectStorage($host, $username, $password, $options);
echo "Deleting Files....";
$container = $objectStorage->with($argv[1])->get();
if (count($container->objects) > 0) {
foreach ($container->objects as $shallowObject) {
$object = $shallowObject->get();
echo $object->getPath()."\n";
$object->delete();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment