0
我知道S3中没有文件夹的概念,它使用平面文件结构。但是,为了简单起见,我将使用术语“文件夹”。使用AWS公开AWS s3目录php使用php
前提条件:
- 一个S3桶叫做foo
- 文件夹FOO已经公开使用AWS管理控制台
- 阿帕奇
- PHP 5
- 标AWS SDK
问题:
可以使用AWS PHP SDK上传文件夹。但是,该文件夹只能由上传该文件夹的用户访问,并且不能公开可读,因为我希望它是。
步骤:
$sharedConfig = [
'region' => 'us-east-1',
'version' => 'latest',
'visibility' => 'public',
'credentials' => [
'key' => 'xxxxxx',
'secret' => 'xxxxxx',
],
];
// Create an SDK class used to share configuration across clients.
$sdk = new Aws\Sdk($sharedConfig);
// Create an Amazon S3 client using the shared configuration data.
$client = $sdk->createS3();
$client->uploadDirectory("foo", "bucket", "foo", array(
'params' => array('ACL' => 'public-read'),
'concurrency' => 20,
'debug' => true
));
成功标准:
我将能够访问一个文件中使用 “静态” 的链接上传的文件夹。 Fx:
https://s3.amazonaws.com/bucket/foo/001.jpg