default: $logger->log(Logger::INFO, "#################### Not downloading '" . $items[0]->name . "' because it's not a file."); break; } } // upload a Hello World file and random file name (note: this seems not to work at this time when you are not logged into the Seafile web frontend). $newFilename = tempnam('.', 'Seafile-PHP-SDK_Test_Upload_'); rename($newFilename, $newFilename . '.txt'); $newFilename .= '.txt'; file_put_contents($newFilename, 'Hello World: ' . date('Y-m-d H:i:s')); $logger->log(Logger::INFO, "#################### Uploading file " . $newFilename); $response = $fileResource->upload($lib, $newFilename, '/'); // get file info $logger->log(Logger::INFO, "#################### Getting file details on " . $newFilename); $result = $fileResource->getFileDetail($lib, '/' . basename($newFilename)); // Update file $logger->log(Logger::INFO, "#################### Power napping 10s before updating the file..."); sleep(10); file_put_contents($newFilename, ' - UPDATED!', FILE_APPEND); $response = $fileResource->update($lib, $newFilename, '/'); $result = unlink($newFilename); // Create dir structure $logger->log(Logger::INFO, "#################### Recursively create directory structure..."); $parentDir = '/'; // Create directory within this folder $directory = 'a/b/c/d/e/f/g/h/i'; // directory structure $recursive = true; // recursive will create parentDir if not already existing $success = $directoryResource->create($lib, $directory, $parentDir, $recursive); print PHP_EOL . 'Done' . PHP_EOL;
/** * test create() with empty dirName. Must yield boolean false. * * @return void */ public function testCreateEmptyDirName() { $directoryResource = new Directory(new \Seafile\Client\Http\Client()); self::assertFalse($directoryResource->create(new Library(), '')); }