Skip to content

Commit

Permalink
Flysystem v2
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Jul 24, 2020
1 parent 91e7a7a commit 81851e5
Show file tree
Hide file tree
Showing 10 changed files with 370 additions and 402 deletions.
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dragonmantank/cron-expression": "^3.0",
"egulias/email-validator": "^2.1.10",
"league/commonmark": "^1.3",
"league/flysystem": "^1.0.34",
"league/flysystem": "^2.0",
"monolog/monolog": "^2.0",
"nesbot/carbon": "^2.17",
"opis/closure": "^3.5.3",
Expand Down Expand Up @@ -82,7 +82,9 @@
"doctrine/dbal": "^2.6",
"filp/whoops": "^2.4",
"guzzlehttp/guzzle": "^6.5.5|^7.0.1",
"league/flysystem-cached-adapter": "^1.0",
"league/flysystem-aws-s3-v3": "^2.0",
"league/flysystem-ftp": "^2.0",
"league/flysystem-sftp": "^2.0",
"mockery/mockery": "^1.3.1",
"orchestra/testbench-core": "^6.0",
"pda/pheanstalk": "^4.0",
Expand Down Expand Up @@ -133,9 +135,9 @@
"fzaninotto/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 (^6.5.5|^7.0.1).",
"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.3.1).",
"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
Original file line number Diff line number Diff line change
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
*/
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
*/
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
*/
public function writeStream($path, $resource, array $options = []);

Expand Down
75 changes: 75 additions & 0 deletions src/Illuminate/Filesystem/AwsS3V3Adapter.php
Original file line number Diff line number Diff line change
@@ -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.

Loading

0 comments on commit 81851e5

Please sign in to comment.