Пример #1
0
 public function store(IFile $file)
 {
     if (is_null($file->getUID())) {
         $file->generateUID();
     }
     $data = ['id' => $file->getUID(), 'name' => $file->getName(), 'full_path' => $file->getFullPath(), 'size' => $file->getSize(), 'content_type' => $file->getContentType(), 'is_image' => $file->isImage()];
     return $this->context->table('media_storage')->insert($data);
 }
Пример #2
0
 /**
  * Save file informations into database and file on disk
  *
  * @param IFile $file
  * @return IFile
  */
 public function save(IFile $file)
 {
     $file->setStoragePath(self::$mediaStoragePath);
     if (is_null($file->getUID())) {
         $file->generateUID();
     }
     $newPath = self::$mediaStoragePath . DIRECTORY_SEPARATOR . $file->getUID();
     $file->save($newPath);
     $this->databaseStorage->store($file);
     return $file;
 }