AWS getobject + 保存时设置权限
AWS getobject + set premission while saving
我正在与 AWS PHP SDK V2.8
和 cakephp V2.3
合作 AWS EC2 Ubuntu machine
。我正在尝试将对象从 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')
));
不执行 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);
我正在与 AWS PHP SDK V2.8
和 cakephp V2.3
合作 AWS EC2 Ubuntu machine
。我正在尝试将对象从 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')
));
不执行 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);