Last active
August 29, 2015 14:01
-
-
Save lorenzoaiello/fb1427c6d65dde7502ed to your computer and use it in GitHub Desktop.
Requires Softlayer ObjectStorage Client (https://github.com/softlayer/softlayer-object-storage-php)
This file contains hidden or 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 | |
/** | |
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