Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Flysystem v2 #33612

Merged
merged 7 commits into from Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions composer.json
Expand Up @@ -23,7 +23,7 @@
"dragonmantank/cron-expression": "^3.0.2",
"egulias/email-validator": "^2.1.10",
"league/commonmark": "^1.3",
"league/flysystem": "^1.1",
"league/flysystem": "^2.0",
"monolog/monolog": "^2.0",
"nesbot/carbon": "^2.31",
"opis/closure": "^3.6",
Expand Down Expand Up @@ -82,7 +82,9 @@
"doctrine/dbal": "^2.6|^3.0",
"filp/whoops": "^2.8",
"guzzlehttp/guzzle": "^7.2",
"league/flysystem-cached-adapter": "^1.0",
"league/flysystem-aws-s3-v3": "^2.0",
"league/flysystem-ftp": "^2.0.0-RC1",
driesvints marked this conversation as resolved.
Show resolved Hide resolved
"league/flysystem-sftp": "^2.0",
"mockery/mockery": "^1.4.2",
"orchestra/testbench-core": "^7.0",
"pda/pheanstalk": "^4.0",
Expand Down Expand Up @@ -134,9 +136,9 @@
"fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).",
"guzzlehttp/guzzle": "Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^7.2).",
"laravel/tinker": "Required to use the tinker console command (^2.0).",
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).",
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).",
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).",
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^2.0).",
"league/flysystem-ftp": "Required to use the Flysystem FTP driver (^2.0).",
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^2.0).",
"mockery/mockery": "Required to use mocking (^1.4.2).",
"nyholm/psr7": "Required to use PSR-7 bridging features (^1.2).",
"pda/pheanstalk": "Required to use the beanstalk queue driver (^4.0).",
Expand Down
10 changes: 0 additions & 10 deletions src/Illuminate/Contracts/Filesystem/FileExistsException.php

This file was deleted.

9 changes: 1 addition & 8 deletions src/Illuminate/Contracts/Filesystem/Filesystem.php
Expand Up @@ -30,9 +30,7 @@ public function exists($path);
* Get the contents of a file.
*
* @param string $path
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
* @return string|null
GrahamCampbell marked this conversation as resolved.
Show resolved Hide resolved
*/
public function get($path);

Expand All @@ -41,8 +39,6 @@ public function get($path);
*
* @param string $path
* @return resource|null The path resource or null on failure.
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
GrahamCampbell marked this conversation as resolved.
Show resolved Hide resolved
*/
public function readStream($path);

Expand All @@ -63,9 +59,6 @@ public function put($path, $contents, $options = []);
* @param resource $resource
* @param array $options
* @return bool
*
* @throws \InvalidArgumentException If $resource is not a file handle.
* @throws \Illuminate\Contracts\Filesystem\FileExistsException
GrahamCampbell marked this conversation as resolved.
Show resolved Hide resolved
*/
public function writeStream($path, $resource, array $options = []);

Expand Down
75 changes: 75 additions & 0 deletions src/Illuminate/Filesystem/AwsS3V3Adapter.php
@@ -0,0 +1,75 @@
<?php

namespace Illuminate\Filesystem;

use Aws\S3\S3Client;
use League\Flysystem\AwsS3V3\AwsS3V3Adapter as S3Adapter;
use League\Flysystem\FilesystemOperator;

class AwsS3V3Adapter extends FilesystemAdapter
{
/**
* The AWS S3 client.
*
* @var S3Client
*/
protected $client;

/**
* Create a new AwsS3V3FilesystemAdapter instance.
*
* @param \League\Flysystem\FilesystemOperator $driver
* @param \League\Flysystem\AwsS3V3\AwsS3V3Adapter $adapter
* @param array $config
* @param \Aws\S3\S3Client $client
* @return void
*/
public function __construct(FilesystemOperator $driver, S3Adapter $adapter, array $config, S3Client $client)
{
parent::__construct($driver, $adapter, $config);

$this->client = $client;
}

/**
* Get the URL for the file at the given path.
*
* @param string $path
* @return string
*
* @throws \RuntimeException
*/
public function url($path)
{
// 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['url'])) {
return $this->concatPathToUrl($this->config['url'], $this->prefixer->prefixPath($path));
}

return $this->client->getObjectUrl(
$this->config['bucket'], $this->prefixer->prefixPath($path)
);
}

/**
* Get a temporary URL for the file at the given path.
*
* @param string $path
* @param \DateTimeInterface $expiration
* @param array $options
* @return string
*/
public function temporaryUrl($path, $expiration, array $options = [])
{
$command = $this->client->getCommand('GetObject', array_merge([
'Bucket' => $this->config['bucket'],
'Key' => $this->prefixer->prefixPath($path),
], $options));

return (string) $this->client->createPresignedRequest(
$command, $expiration
)->getUri();
}
}
71 changes: 0 additions & 71 deletions src/Illuminate/Filesystem/Cache.php

This file was deleted.