getUniqueFilename($label); $stream = $fileSource instanceof File ? $fileSource->readStream() : fopen($fileSource, 'r'); $this->getFileSystem()->writeStream($filename, $stream); if (is_resource($stream)) { fclose($stream); } return $filename; } public function deleteDirectory(string $directoryPath): bool { return $this->getFilesystem()->deleteDir($directoryPath); } public function getFileSize($link) { return $this->getFilesystem()->getSize($link); } /** * * @param string $link * @return StreamInterface */ public function getFileStream($link) { $resource = $this->getFilesystem()->readStream($link); return new Stream($resource); } /** * (non-PHPdoc) * @see \oat\taoMediaManager\model\fileManagement\FileManagement::retrieveFile() */ public function retrieveFile($link) { $this->logWarning('Deprecated'); return null; } /** * (non-PHPdoc) * @see \oat\taoMediaManager\model\fileManagement\FileManagement::deleteFile() */ public function deleteFile($link) { return $this->getFilesystem()->delete($link); } /** * @return Filesystem */ protected function getFilesystem() { $fs = $this->getServiceLocator()->get(FileSystemService::SERVICE_ID); return $fs->getFileSystem($this->getOption(self::OPTION_FS)); } /** * Create a new unique filename based on an existing filename * * @param string $fileName * @return string */ protected function getUniqueFilename($fileName) { $returnValue = uniqid(hash('crc32', $fileName)); $ext = @pathinfo($fileName, PATHINFO_EXTENSION); if (!empty($ext)) { $returnValue .= '.' . $ext; } return $returnValue; } }