Created
December 20, 2016 16:10
-
-
Save yisraeldov/9e5d3d50a8ede33ede63d4435800c8bc to your computer and use it in GitHub Desktop.
Using s3 with flysystem and CacheControl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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