Skip to content

Instantly share code, notes, and snippets.

@yisraeldov
Created December 20, 2016 16:10
Show Gist options
  • Save yisraeldov/9e5d3d50a8ede33ede63d4435800c8bc to your computer and use it in GitHub Desktop.
Save yisraeldov/9e5d3d50a8ede33ede63d4435800c8bc to your computer and use it in GitHub Desktop.
Using s3 with flysystem and CacheControl
<?php
$loader = require __DIR__ . '/vendor/autoload.php';
$client = new Aws\S3\S3Client(
[
'credentials' => [
'key' => $key,
'secret' => $secret
],
'region' => 'eu-west-1',
'version' => 'latest',
]);
$adapter = new \League\Flysystem\AwsS3v3\AwsS3Adapter($client,$bucket,null,[
'CacheControl' => 'no-cache',
]);
$driver = new \League\Flysystem\Filesystem($adapter,new \League\Flysystem\Config(
// ['disable_asserts'=>true] // use this if you don't have rights to list
));
$stream = fopen('test.png','rb');
$result = $driver->putStream($file = '/test/test'.date('U').'.png',$stream, [
// 'CacheControl' => 'no-cache', //Set Cache Controll per DIR
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment