Example #1
0
 public static function factory(Storage $storage, $row)
 {
     $tempfile = new File($storage);
     $tempfile->setFileID($row["fileid"]);
     $tempfile->setFilename($row["filename"]);
     $tempfile->setExportFilename($row["exportfilename"]);
     $tempfile->setMimeType($row["mimetype"]);
     return $tempfile;
 }
Example #2
0
 /**
  * Default factory for uploaded files
  * @param string $field
  * @param array $input
  * @return \qio\File\Upload\File
  */
 public function getFile($field, array $input)
 {
     $file = new File();
     $file->setFieldName($field);
     $file->setOriginalName($input['name']);
     $file->setTemporaryName($input['tmp_name']);
     $file->setMimeType($input['type']);
     $file->setSize($input['size']);
     $file->setErrorCode($input['error']);
     return $file;
 }
 public function getTempFile()
 {
     if ($this->tempfile == null) {
         $this->tempfile = new TempFile($this->getStorage());
         $file = new File($this->getStorage());
         $file->setMimeType("application/zip");
         $file->setExportFilename("download.zip");
         $file->save();
         $this->tempfile->setUserID($this->getUserID());
         $this->tempfile->setFile($file);
         $this->tempfile->setTimestamp(time());
         $this->tempfile->save();
     }
     return $this->tempfile;
 }
Example #4
0
 /**
  * Deletes a file.
  *
  * Called when this component receives an HTTP DELETE request to
  * /zip/$a/$b/$c/$file.
  *
  * @param string $hash The hash of the file which should be deleted.
  */
 public function deleteZip($callName, $input, $params = array())
 {
     $path = array(self::getBaseDir(), $params['a'], $params['b'], $params['c'], $params['file']);
     $filePath = implode('/', array_slice($path, 0));
     if (strlen($filePath) > 0 && file_exists($this->config['DIR']['files'] . '/' . $filePath)) {
         // after the successful deletion, we want to return the file data
         $file = new File();
         $file->setAddress($filePath);
         $file->setFileSize(filesize($this->config['DIR']['files'] . '/' . $filePath));
         $file->setHash(sha1_file($this->config['DIR']['files'] . '/' . $filePath));
         $file->setMimeType("application/zip");
         // removes the file
         unlink($this->config['DIR']['files'] . '/' . $filePath);
         // the removing/unlink process failed, if the file still exists.
         if (file_exists($this->config['DIR']['files'] . '/' . $filePath)) {
             return Model::isProblem(new File());
         }
         // the file is removed
         return Model::isCreated($file);
     } else {
         // file does not exist
         return Model::isProblem(new File());
     }
 }
Example #5
0
 public function getFileVariable($name)
 {
     if (!$this->hasFileVariable($name)) {
         return null;
     }
     $file = new File($this->getStorage());
     $file->setExportFilename($_FILES[$name]["name"]);
     $file->setMimeType($_FILES[$name]["type"]);
     if (!move_uploaded_file($_FILES[$name]["tmp_name"], $file->getAbsoluteFilename())) {
         return null;
     }
     $file->save();
     return $file;
 }