I'm trying to wirte a function which is downloading content from my S3 bucket. The main problem I have is that, $s3->getObject
returns class with private properties.
I'm using "aws/aws-sdk-php": "^3.54"
via composer and this are my methods.
My main controller
public function download($idDocument = null) {
$document = $this->Documents->get(['where' => ['id_document' => $idDocument]]);
$document = $document[0];
// Download file from S3
$this->load->library('s3');
$response = $this->s3->downloadFromS3($document->path);
var_dump($response);
die();
}
This is my S3 library, which I'm calling in upper controller
public function authorize() {
$s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'eu-central-1',
'credentials' => [
'key' => $this->config->config['s3_access_key'],
'secret' => $this->config->config['s3_secret_key']
]
]);
return $s3;
}
public function downloadFromS3($uniqueIdTypeAndName) {
$s3 = $this->authorize();
$object = $s3->getObject([
'Bucket' => $this->config->config['s3_bucket_name'],
'Key' => $uniqueIdTypeAndName
]);
return $object;
}
And this is the response if I var_dump($response);
of my library function
So when I try to call $response->ContentType i get Message: Undefined property: Aws\Result::$ContentType
What can I do so my class will be public and the properties will be accessible? If you need any additional informations, please let me know and I will provide. Thank you