我正在使用此PHP
库在AWS-S3上上传文件。
https://github.com/tpyo/amazon-s3-php-class
$this->load->library('aws/s3');
S3::setAuth('xxxxx', 'yyyyy');
S3::putObject(S3::inputFile(APPPATH.'index.html'),
'test_con',
time().'.html',
S3::ACL_PUBLIC_READ,
array(),
array(),
S3::STORAGE_CLASS_STANDARD
);
如您所见,我正在使用public-read
。但是,在AWS控制台中,我无法下载/查看该文件。错误:Directory access is forbidden.
奇怪的情况:如果我使用text(e.g.: xyz)
代替此行:S3::inputFile(APPPATH.'index.html')
。然后我可以访问该文件。
输出:
$d = S3::getObject('test_con', '1471467180.html');
print_r($d);
stdClass Object ( [error] => [body] =>
Directory access is forbidden.
[headers] => Array ( [date] => 1471533372 [time] => 1471467193 [hash] => 6b37305eedfsdf3234242431bfsffd5dfd3bb1 [type] => text/html [size] => 123 ) [code] => 200 )