I am working on a project which is in cakephp V2.3 with AWS PHP SDK V2.8. which is hosted on AWS ec2 ubuntu machine. I am trying to get the image which is hosted on AWS S3 by following code
try {
$resultS3 = $this->Amazon->S3->getObject(array(
'Bucket' => 'mytest.sample',
'Key' => 'files/user/image/35/1440319731.png',
));
} catch (S3Exception $e) {
pr($e); //die;
}
header("Content-Type: {$resultS3['ContentType']}");
echo $resultS3['Body'];
but I am getting following message.
The image “http://ift.tt/1KHOmlP” cannot be displayed because it contains errors.
and the response is following
Guzzle\Service\Resource\Model Object
(
[structure:protected] =>
[data:protected] => Array
(
[Body] => Guzzle\Http\EntityBody Object
(
[contentEncoding:protected] =>
[rewindFunction:protected] =>
[stream:protected] => Resource id #20
[size:protected] =>
[cache:protected] => Array
(
[wrapper_type] => PHP
[stream_type] => TEMP
[mode] => w+b
[unread_bytes] => 0
[seekable] => 1
[uri] => php://temp
[is_local] => 1
[is_readable] => 1
[is_writable] => 1
)
[customData:protected] => Array
(
[default] => 1
)
)
[DeleteMarker] =>
[AcceptRanges] => bytes
[Expiration] =>
[Restore] =>
[LastModified] => Sun, 23 Aug 2015 08:49:22 GMT
[ContentLength] => 207719
[ETag] => "a alphanumeric value"
[MissingMeta] =>
[VersionId] =>
[CacheControl] =>
[ContentDisposition] =>
[ContentEncoding] =>
[ContentLanguage] =>
[ContentRange] =>
[ContentType] => image/png
[Expires] =>
[WebsiteRedirectLocation] =>
[ServerSideEncryption] => aws:kms
[SSECustomerAlgorithm] =>
[SSECustomerKeyMD5] =>
[SSEKMSKeyId] => arn:aws:kms:ap-southeast----
[StorageClass] =>
[RequestCharged] =>
[ReplicationStatus] =>
[RequestId] => 367A8A19F55234F9
)
)
I create a custom component for accessing all features of SDK. with the reference of http://ift.tt/1Jc0cPN.
can anyone tell me where I am doing it wrong.
Aucun commentaire:
Enregistrer un commentaire