我正在使用AWS EC2 Ubuntu machine
和AWS PHP SDK V2.8
处理cakephp V2.3
。我正在尝试将对象从AWS S3
下载到我的AWS服务器。工作正常只是一个问题是如何设置文件644
的权限777
。
这是我的代码。
$saveAs = "/var/www/html/app/webroot/files/image/" . $result[$type][0]['id'] . "/" . $result[$type][0]['attachment'];
$key = "files/image/" . $result[$type][0]['id'] . "/" . $result[$type][0]['attachment'];
$result = $this->Amazon->S3->getObject(array(
'Bucket' => 'mytest.sample',
// 'Key' => 'avtar-auth_test_latest5.png',
'Key' => $key,
'version' => 'latest',
'SaveAs' => $saveAs
));
我也试过
$saveAs = "/var/www/html/app/webroot/files/image/" . $result[$type][0]['id'] . "/" . $result[$type][0]['attachment'];
$key = "files/image/" . $result[$type][0]['id'] . "/" . $result[$type][0]['attachment'];
$result = $this->Amazon->S3->getObject(array(
'Bucket' => 'mytest.sample',
// 'Key' => 'avtar-auth_test_latest5.png',
'Key' => $key,
'version' => 'latest',
'SaveAs' => chmod($saveAs,'0777')
));
答案 0 :(得分:1)
不是执行chmod函数并将结果传递给getObject函数,而是在使用单独的语句保存文件后修改文件权限:
$saveAs = "/var/www/html/app/webroot/files/image/" . $result[$type][0]['id'] . "/" . $result[$type][0]['attachment'];
$key = "files/image/" . $result[$type][0]['id'] . "/" . $result[$type][0]['attachment'];
$result = $this->Amazon->S3->getObject(array(
'Bucket' => 'mytest.sample',
// 'Key' => 'avtar-auth_test_latest5.png',
'Key' => $key,
'version' => 'latest',
'SaveAs' => $saveAs
));
chmod($saveAs,0777);