Ejemplo n.º 1
0
 /**
  * get file content from id
  * @NoCSRFRequired
  * @PublicPage
  */
 public function downloadSensorML($uuid)
 {
     $systems = $this->systemMapper->getByUuid($uuid);
     if ($systems !== null) {
         $fileIds = array();
         $resultFiles = new \PharData(sys_get_temp_dir() . "/{$uuid}.zip");
         foreach ($systems as $system) {
             $fileId = $system->getFileId();
             if (!in_array($fileId, $fileIds)) {
                 $fileIds[] = $fileId;
                 $cacheInfo = FileCacheDao::getCacheInfo($fileId);
                 if ($cacheInfo !== null) {
                     $fileInfo = FileCacheDao::getFileInfo($cacheInfo['storage'], $cacheInfo['path'], $system->getPharPath());
                     $content = FileCacheDao::getContentByUrn($fileInfo['urn']);
                     $resultFiles->addFromString($uuid . "_" . $fileId . ".xml", $content);
                 }
             }
         }
         $fullPath = $resultFiles->getPath();
         if ($fd = fopen($fullPath, "r")) {
             $path_parts = pathinfo($fullPath);
             header("Content-type: application/octet-stream");
             header("Content-Disposition: filename=\"" . $path_parts["basename"] . "\"");
             while (!feof($fd)) {
                 $buffer = fread($fd, 2048);
                 echo $buffer;
             }
         }
         fclose($fd);
     }
     return new NotFoundResponse();
 }
Ejemplo n.º 2
0
 public static function getContent($numericId, $path)
 {
     $fileInfo = FileCacheDao::getFileInfo($numericId, $path);
     return FileCacheDao::getContentByUrn($fileInfo['urn']);
 }