getDriver()->setUploadedFile($file)->upload(); } catch (\Exception $exception) { throw new \RuntimeException($exception->getMessage()); } } /** * get driver * */ public function getDriver() { $drivers = $this->getDrivers(); $driver = $drivers[$this->driver] ?? null; if (! $driver) { throw new \RuntimeException('Upload Driver Not Found'); } return app($driver); } /** * set driver * * @param string $driver * @return $this */ public function setDriver(string $driver): static { $this->driver = $driver; return $this; } /** * get drivers * * @return string[] */ public function getDrivers(): array { return [ 'local' => LocalUpload::class, 'HuaweiOBS' => HuaweiOBSUpload::class, ]; } }