We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
Thanks for your article. It was very helpful! However, I had to make some changes to your code to get it to work. I am not sure if this is because of changes in Laravel v9 or not.
use Illuminate\Filesystem\AwsS3V3Adapter;
AwsS3V3Adapter::macro('temporaryUploadUrl', function ($path, $expiration, array $options = []) {
/** @phpstan-ignore-next-line */
$command = $this->client->getCommand('PutObject', array_merge([
'Bucket' => $this->config['bucket'], /* @phpstan-ignore-line */
'Key' => $this->prefixer->prefixPath($path), /* @phpstan-ignore-line */
], $options));
/** @phpstan-ignore-next-line */
$uri = $this->client->createPresignedRequest(
$command, $expiration, $options
)->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 (isset($this->config['temporary_url'])) {
/** @phpstan-ignore-next-line */
$uri = $this->replaceBaseUrl($uri, $this->config['temporary_url']);
}
return (string) $uri;
});
Hopefully this is helpful to someone.
For anyone reading this, this is now included in Laravel 9.52 and Laravel 10:
https://laravel.com/docs/10.x/filesystem#temporary-upload-urls