public function getFile() { if ($this->hasRequestParameter('uri')) { $uri = urldecode($this->getRequestParameter('uri')); $mediaSource = new MediaSource(array()); $filepath = $mediaSource->download($uri); if ($this->hasRequestParameter('xml')) { $this->returnJson(htmlentities(file_get_contents($filepath))); } else { \tao_helpers_Http::returnFile($filepath, false); } } else { throw new \common_exception_Error('invalid media identifier'); } }
public function getFile() { if ($this->hasRequestParameter('uri')) { $uri = urldecode($this->getRequestParameter('uri')); $mediaSource = new MediaSource(array()); $fileInfo = $mediaSource->getFileInfo($uri); $link = $fileInfo['link']; $fileManagement = $this->getServiceManager()->get(FileManagement::SERVICE_ID); if ($fileInfo['mime'] === 'application/qti+xml') { \tao_helpers_Http::returnStream($fileManagement->getFileStream($link)); return; } if ($this->hasRequestParameter('xml')) { $this->returnJson(htmlentities((string) $fileManagement->getFileStream($link))); } else { \tao_helpers_Http::returnStream($fileManagement->getFileStream($link), $fileInfo['mime']); } } else { throw new \common_exception_Error('invalid media identifier'); } }
/** * @expectedException \tao_models_classes_FileNotFoundException * @expectedExceptionMessage File A Fake link not found */ public function testGetFileInfoFail() { $link = 'A Fake link'; $this->mediaManagerManagement->getFileInfo($link); }