Beispiel #1
0
        case 'file':
            $logger->log(Logger::INFO, "#################### Downloading file '" . $items[0]->name . "' to '" . $saveTo);
            $downloadResponse = $fileResource->downloadFromDir($lib, $items[0], $saveTo, '/');
            break;
        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
Beispiel #2
0
 /**
  * Try to upload a non-existent local file
  *
  * @return void
  * @throws \Exception
  */
 public function testUploadDoesNotExist()
 {
     $filename = uniqid();
     $fileResource = new File($this->getMockedClient(new Response()));
     $this->setExpectedException('Exception');
     $fileResource->upload(new Library(), $filename);
     $this->fail('Exception expected');
 }