disk->value); $prefix = Config::string('storage-service.prefix', 'media'); if (! ($disk instanceof AwsS3V3Adapter)) { throw new \UnexpectedValueException("Expected {$s3->disk->value} to be an S3 disk"); } $trimmedPath = ltrim($path, '/'); $fullPath = ltrim(trim($prefix, '/') . "/{$trimmedPath}", '/'); $s3Url = $disk->url($fullPath); return redirect()->away($s3Url, 301, [ 'Cache-Control' => 'public, max-age=31536000, immutable', ]); } }