I am working on AWS EC2 Ubuntu machine
with AWS PHP SDK V2.8
and cakephp V2.3
. I am trying to download the object from AWS S3
to my AWS Server. It is working fine just a issue is How can I set permission 644
to 777
of the file.
Here is my code.
$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
));
I also tried
$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')
));
Instead of executing the chmod function and passing the result of that into the getObject function, modify the file permissions after the file has been saved using a separate statement:
$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);