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

[5.2] Allow passing along options to the S3 client #13791

Merged
merged 2 commits into from
May 31, 2016
Merged

[5.2] Allow passing along options to the S3 client #13791

merged 2 commits into from
May 31, 2016

Conversation

LasseRafn
Copy link
Contributor

I found it impossible (un-necessarily clunky) to add cache headers or similar to S3 objects. This allows you to.

A new key in filesystems.php and you're good to go. Example:

 's3' => [
            'driver' => 's3',
            'key'    => env('S3_KEY'),
            'secret' => env('S3_SECRET'),
            'region' => 'eu-central-1',
            'bucket' => 'my-demo-bucket',
            'options' => [
                'CacheControl' => 'max_age=2592000'
            ]
        ],

——

Any other solution would be great though 👍

I found it impossible (un-necessarily clunky) to add cache headers or similar to S3 objects. This allows you to.

A new key in filesystems.php and you're good to go. Example:

````
 's3' => [
            'driver' => 's3',
            'key'    => env('S3_KEY'),
            'secret' => env('S3_SECRET'),
            'region' => 'eu-central-1',
            'bucket' => 'my-demo-bucket',
			'options' => [
				'CacheControl' => 'max_age=2592000'
			]
        ],
````
@GrahamCampbell GrahamCampbell changed the title Allow passing along options to the S3 client [5.2] Allow passing along options to the S3 client May 31, 2016
@@ -188,7 +188,7 @@ public function createS3Driver(array $config)
$root = isset($s3Config['root']) ? $s3Config['root'] : null;

return $this->adapt($this->createFlysystem(
new S3Adapter(new S3Client($s3Config), $s3Config['bucket'], $root), $config
new S3Adapter(new S3Client($s3Config), $s3Config['bucket'], $root, $config['options'] ?: []), $config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break existing apps if the options index doesn't exist. Please use an isset check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah well I guess if it does not support ?: it will break, sorry. I'll add a check instead

Added isset check
@taylorotwell taylorotwell merged commit 9a6c830 into laravel:5.2 May 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants