/** * Get the URL for the file at the given path. * * @param string $path * @return string */ public function url($path) { $adapter = $this->driver->getAdapter(); if (method_exists($adapter, 'getUrl')) { return $adapter->getUrl($path); } elseif ($adapter instanceof AwsS3Adapter) { $path = $adapter->getPathPrefix() . $path; return $adapter->getClient()->getObjectUrl($adapter->getBucket(), $path); } elseif ($adapter instanceof LocalAdapter) { $config = $this->driver->getConfig(); if ($config->has('url')) { return $config->get('url') . '/' . $path; } $path = '/storage/' . $path; return Str::contains($path, '/storage/public') ? Str::replaceFirst('/public', '', $path) : $path; } else { throw new RuntimeException('This driver does not support retrieving URLs.'); } }