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); }
/** * @param IFile $file * @param $path * @return IFile */ public function publishFile(IFile $file, $path) { $onlyPath = dirname($path); if (!file_exists($onlyPath)) { FilesystemStorage::mkdir($onlyPath, 0777, true); } $file->save($path); return $file; }