Ejemplo n.º 1
0
 /**
  * Load this object
  * @since Version 3.10.0
  * @return void;
  */
 private function getFootage()
 {
     $data = $this->db->fetchRow("SELECT * FROM railcam_footage WHERE id = ?", $this->id);
     $data['fileinfo'] = json_decode($data['fileinfo'], true);
     $this->timeStamp = new DateTime($data['datestored']);
     $this->setCamera(new Camera($data['railcam_id']));
     $this->type = $data['type'];
     $storageObject = new Storage($data['storage_id']);
     $this->footageData = ["id" => $data['id'], "camera" => $this->cameraObject->getArray(), "type" => $this->type, "url" => ["original" => $storageObject->getWebUrl($data['fileinfo'])]];
     return;
 }
Ejemplo n.º 2
0
 /**
  * Actually store the file
  * @since Version 3.10.0
  * @param string $tmpFile
  * @param string $origFile
  * @return void
  */
 private function storeFile($tmpFile, $origFile)
 {
     if (!file_exists($tmpFile)) {
         throw new InvalidArgumentException("Supplied file path " . $tmpFile . " does not exist");
     }
     $dstPath = vsprintf("%s%s/%s/%s/%s", [$this->config['storageRoot'], date("Y"), date("m"), date("d"), $origFile]);
     $ext = pathinfo($dstPath, PATHINFO_EXTENSION);
     $dstPath = str_replace("." . $ext, microtime(true) . "." . $ext, $dstPath);
     $type = mime_content_type($dstPath);
     if (file_exists($dstPath)) {
         throw new Exception("Could not store railcam footage in LocalFS - destination file already exists");
     }
     if (!is_dir(dirname($dstPath))) {
         mkdir(dirname($dstPath), 0755, true);
     }
     if (!is_writable(dirname($dstPath))) {
         throw new Exception("The destination path " . $dstPath . " is not writable");
     }
     move_uploaded_file($tmpFile, $dstPath);
     $this->fileInfo = ["path" => str_replace($this->config['storageRoot'], "", $dstPath), "filesize" => filesize($dstPath), "mime" => mime_content_type($dstPath), "type" => StorageGizmo::getTypeFromMime($type), "duration" => 0, "remote_id" => 0];
 }