*/ require_once '../fts/utils.php'; /* steal fts utils ;) */ require_once 'lib/StorageClient/StorageClient.class.php'; require_once __DIR__ . DIRECTORY_SEPARATOR . 'testUtils.php'; /* generate some random names in order to be reasonably sure they don't exist yet */ $fileName = 'demoFileName.txt'; $otherFileName = 'otherDemoFileName.txt'; $dirName = 'demoDirectory'; $otherDirName = 'otherDemoDirectory'; // $dbg = TRUE; $dbg = FALSE; $storageProvider = array('displayName' => 'Test Server', 'apiUrl' => 'http://localhost/filetrader/fts', 'consumerKey' => '12345', 'consumerSecret' => '54321'); $sc = new StorageClient($storageProvider); $sc->performDecode(TRUE); handleResponse("ping " . $storageProvider['apiUrl'], $dbg, $sc->call("pingServer")); handleNegativeResponse("mkdir {$dirName}/{$otherDirName}", $dbg, $sc->call("createDirectory", array('relativePath' => "{$dirName}/{$otherDirName}"), "POST")); handleResponse("mkdir {$dirName}", $dbg, $sc->call("createDirectory", array('relativePath' => $dirName), "POST")); handleResponse("mkdir {$dirName}/{$otherDirName}", $dbg, $sc->call("createDirectory", array('relativePath' => "{$dirName}/{$otherDirName}"), "POST")); handleNegativeResponse("mkdir {$dirName}/{$otherDirName}/.test", $dbg, $sc->call("createDirectory", array('relativePath' => "{$dirName}/{$otherDirName}/.test"), "POST")); handleNegativeResponse("mkdir ../test", $dbg, $sc->call("createDirectory", array('relativePath' => "../test"), "POST")); handleNegativeResponse("setdesc {$fileName}", $dbg, $sc->call('setDescription', array('relativePath' => $fileName, 'fileDescription' => 'Hello World'), "POST")); handleNegativeResponse("getdesc {$fileName}", $dbg, $sc->call('getDescription', array('relativePath' => $fileName), "POST")); /* upload a file, use random name, but actually send COPYING as it is * there anyway... */ $r = handleResponse("utoken {$fileName}", $dbg, $sc->call("getUploadToken", array('relativePath' => $fileName, 'fileSize' => filesize("COPYING")), "POST")); handleResponse("ufile {$fileName}", $dbg, uploadFile($r->uploadLocation, "COPYING", 1024)); handleResponse("setdesc {$fileName}", $dbg, $sc->call('setDescription', array('relativePath' => $fileName, 'fileDescription' => "'Hello World'"), "POST")); $d = handleResponse("getdesc {$fileName}", $dbg, $sc->call('getDescription', array('relativePath' => $fileName), "POST")); if ($d->fileDescription !== "'Hello World'") { die("FAIL");
require_once 'lib/StorageClient/StorageClient.class.php'; /* Disable Caching */ header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past if (!isset($config) || !is_array($config)) { die("broken or missing configuration file?"); } date_default_timezone_set(getConfig($config, 'time_zone', FALSE, 'Europe/Amsterdam')); try { if (getConfig($config, 'ssl_only', FALSE, FALSE)) { if (getProtocol() != "https://") { throw new Exception("only available through secure connection"); } } set_include_path(get_include_path() . PATH_SEPARATOR . getConfig($config, "oauth_lib_dir", TRUE)); $params = $_REQUEST; $endpoint = $params['proxy_to']; $key = $params['proxy_consumer_key']; $secret = $params['proxy_consumer_secret']; $action = $params['action']; unset($params['proxy_to']); unset($params['proxy_consumer_key']); unset($params['proxy_consumer_secret']); unset($params['action']); $sc = new StorageClient(array('apiUrl' => $endpoint, 'consumerKey' => $key, 'consumerSecret' => $secret)); echo $sc->call($action, $params, $_SERVER['REQUEST_METHOD']); exit(0); } catch (Exception $e) { }
*/ require_once 'config.php'; require_once 'utils.php'; require_once 'tests/testUtils.php'; if (!isset($config) || !is_array($config)) { die("broken or missing configuration file?"); } date_default_timezone_set(getConfig($config, 'time_zone', FALSE, 'Europe/Amsterdam')); set_include_path(get_include_path() . PATH_SEPARATOR . getConfig($config, "oauth_lib_dir", TRUE)); require_once 'lib/StorageClient/StorageClient.class.php'; // $dbg = TRUE; $dbg = FALSE; $storageProvider = array('displayName' => 'Test Server', 'apiUrl' => 'http://localhost/fts', 'consumerKey' => 'demo', 'consumerSecret' => 'a1bf8348016c52f81498cd576d55a932'); $sc = new StorageClient($storageProvider); $sc->performDecode(TRUE); handleResponse("ping " . $storageProvider['apiUrl'], $dbg, $sc->call("pingServer")); if (!isset($argv) || empty($argv[1])) { die("Specify path to upload\n"); } $pth = realpath($argv[1]); if ($pth === FALSE) { die("Path does not exist\n"); } $rootDir = dirname($pth); $relativePath = basename($pth); echo "Recursivly uploading '{$pth}'...\n"; uploadPath($sc, $dbg, $rootDir, $relativePath); function uploadPath($sc, $dbg, $rootDir, $relativePath) { handleResponse("mkdir {$relativePath}", $dbg, $sc->call("createDirectory", array('relativePath' => $relativePath), "POST")); $fullDir = $rootDir . DIRECTORY_SEPARATOR . $relativePath;