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); }
/** * 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; }