Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/Illuminate/Filesystem/FilesystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use League\Flysystem\Sftp\SftpAdapter as Sftp;
use PHPUnit\Framework\Assert as PHPUnit;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UriInterface;
use RuntimeException;
use Symfony\Component\HttpFoundation\StreamedResponse;

Expand Down Expand Up @@ -593,9 +594,18 @@ public function getAwsTemporaryUrl($adapter, $path, $expiration, $options)
'Key' => $adapter->getPathPrefix().$path,
], $options));

return (string) $client->createPresignedRequest(
$uri = $client->createPresignedRequest(
$command, $expiration
)->getUri();

// If an explicit base URL has been set on the disk configuration then we will use
// it as the base URL instead of the default path. This allows the developer to
// have full control over the base path for this filesystem's generated URLs.
if (! is_null($url = $this->driver->getConfig()->get('url'))) {
$uri = $this->replaceBaseUrl($uri, $url);
}

return (string) $uri;
}

/**
Expand All @@ -610,6 +620,20 @@ protected function concatPathToUrl($url, $path)
return rtrim($url, '/').'/'.ltrim($path, '/');
}

/**
* Replace base parts of UriInterface by values from URL.
*
* @param UriInterface $uri
* @param string $url
* @return UriInterface
*/
protected function replaceBaseUrl($uri, $url)
{
$parsed_url = parse_url($url);

return $uri->withScheme($parsed_url['scheme'])->withHost($parsed_url['host']);
}

/**
* Get an array of all files in a directory.
*
Expand Down