/** * Test preparation: create a binary which can be used for view * testing. */ function setUp() { parent::setUp(); $storage = new binarypool_storage('test'); $asset = $storage->save('IMAGE', array('_' => array('file' => $this->testfile))); $this->assertNotNull($asset); $this->assetFile = $asset; $this->assetId = '096dfa489bc3f21df56eded2143843f135ae967e'; binarypool_lastmodified::resetMemoryCache(); binarypool_views::$lastModified = null; binarypool_views::$storageFactory = null; }
protected function upload($bucket) { $this->checkInput(); // Get params $type = $this->request->getParam('Type'); $callback = $this->request->getParam('Callback', ''); $files = $this->getFiles(); $url = $this->request->getParam('URL'); $created = true; $storage = new binarypool_storage($bucket); // 304 not modified if (0 == count($files) && !empty($url)) { $symlink = binarypool_views::getDownloadedViewPath($bucket, $url); $asset = $storage->getAssetForLink($symlink); $this->log->info("Unmodified file %s", $asset); $created = false; } else { // Save file $asset = $storage->save($type, $files); $this->log->info("Created file %s", $asset); } foreach ($files as $rendition => $file) { unlink($file['file']); } if ($callback !== '') { $storage->addCallback($asset, $callback); } $metadata = array(); $metadata['URL'] = $url; if ($created) { binarypool_views::created($bucket, $asset, $metadata); } else { $assetObj = $storage->getAssetObject($asset); binarypool_views::updated($bucket, $asset, $assetObj, $metadata); } $this->setResponseCode(201); $this->response->setHeader('Location', $asset); $this->response->setHeader('X-Asset', $asset); $xml = "<status method='post'><asset>" . htmlspecialchars($asset) . "</asset></status>"; array_push($this->data, new api_model_xml($xml)); }