_path = $path; } final public function getPath(): string { return $this->_path; } public function getEntity(): FileEntity { if ($this->_entity === null) { $this->_entity = new FileEntity(); $this->_entity->setPath($this->getPath()); } return $this->_entity; } public function save($content): null|FileEntity { $fullPath = WRITEPATH . $this->getUploadPath() . DIRECTORY_SEPARATOR . $this->getPath(); if (!is_dir($fullPath)) { if (!mkdir($fullPath)) { throw new \Exception("Make Directory Error:" . $fullPath); } } $entity = $this->getEntity(); $saveFile = $fullPath . DIRECTORY_SEPARATOR . $entity->getTitle(); log_message("debug", "Storage Save-> " . $saveFile); if (!file_put_contents($saveFile, $content)) { return null; } //File형식에 따른 MimeType 지정 $entity->setMimeType(mime_content_type($saveFile)); return $entity; } }