How to access Amazon s3 private slave through Zend_Service_Amazon_S3

I created a bucket on amazon s3 and I saved some images in this bucket inside the folder. All images are private, and I use the Zend_Service_Amazon_S3 Zend class.

Please let me know how I can access private images.

Thanks Pravin

+3
source share
2 answers

You can accomplish this task by making a private url.

public function get_s3_signed_url($bucket, $resource, $AWS_S3_KEY, $AWS_s3_secret_key, $expire_seconds) {
     $expires = time()+$expire_seconds;
     // S3 Signed URL creation
     $string_to_sign = "GET\n\n\n{$expires}\n/".str_replace(".s3.amazonAWS.com","", $bucket)."/$resource";
     $signature = urlencode(base64_encode((hash_hmac("sha1", utf8_encode($string_to_sign), $AWS_s3_secret_key, TRUE))));

     $authentication_params = "AWSAccessKeyId=".$AWS_S3_KEY;
     $authentication_params.= "&Expires={$expires}";
     $authentication_params.= "&Signature={$signature}";
     return $link = "http://s3.amazonAWS.com/{$bucket}/{$resource}?{$authentication_params}";
}

now use this URL to access.

+6
source

Try the following: It will return binary data for the file stored in the Amazon S3 bucket.

require_once 'Zend/Service/Amazon/S3.php';
$s3 = new Zend_Service_Amazon_S3($my_aws_key, $my_aws_secret_key);
echo $s3->getObject("my-own-bucket/myobject");

: http://framework.zend.com/manual/de/zend.service.amazon.s3.html
# 1

+2

Source: https://habr.com/ru/post/1659891/


All Articles