public function testReadFiles() { $root = $this->tmpDir; file_put_contents($root . "/upload", "test"); $id1 = $this->client->uploadFile($root . "/upload", (new FileUploadOptions())->setTags(["docker-bundle-test"])); $id2 = $this->client->uploadFile($root . "/upload", (new FileUploadOptions())->setTags(["docker-bundle-test"])); $reader = new Reader($this->client); $configuration = [["tags" => ["docker-bundle-test"]]]; $reader->downloadFiles($configuration, $root . "/download"); $this->assertEquals("test", file_get_contents($root . "/download/" . $id1 . '_upload')); $this->assertEquals("test", file_get_contents($root . "/download/" . $id2 . '_upload')); $adapter = new FileManifestAdapter(); $manifest1 = $adapter->readFromFile($root . "/download/" . $id1 . "_upload.manifest"); $manifest2 = $adapter->readFromFile($root . "/download/" . $id2 . "_upload.manifest"); $this->assertEquals($id1, $manifest1["id"]); $this->assertEquals($id2, $manifest2["id"]); }
/** * @param $fileInfo * @param $destination * @throws \Exception */ protected function writeFileManifest($fileInfo, $destination) { $manifest = array("id" => $fileInfo["id"], "name" => $fileInfo["name"], "created" => $fileInfo["created"], "is_public" => $fileInfo["isPublic"], "is_encrypted" => $fileInfo["isEncrypted"], "tags" => $fileInfo["tags"], "max_age_days" => $fileInfo["maxAgeDays"], "size_bytes" => $fileInfo["sizeBytes"]); $adapter = new FileAdapter($this->getFormat()); try { $adapter->setConfig($manifest); $adapter->writeToFile($destination); } catch (InvalidConfigurationException $e) { throw new InputOperationException("Failed to write manifest for file {$fileInfo['id']} - {$fileInfo['name']}.", $e); } }