How to Connect S3 Aws Bucket And Get Image

public static function productImageGet($isbn13)

{ $path = getcwd(); require_once($path.’/application/third_party/s3/vendor/autoload.php’); $s3Url = “Yoururl“; $bucket = ‘Yourbucketname’; $credentials = new Aws\Credentials\Credentials(‘enter your accesskey’, ‘enteryourscretekey’); $s3 = new Aws\S3\S3Client([ ‘version’ => ‘latest’, ‘region’ => ‘eu-usa-1’, ‘credentials’ => $credentials ]); if($s3->doesObjectExist($bucket, ‘images/’.$isbn13.’.jpg’)) { return $s3Url.$isbn13.”.jpg”; } else { return $s3Url.”no-product-image.jpg”; // if($s3->doesObjectExist($bucket, ‘images/no-product-image.jpg’)) // { // return $s3Url.”no-product-image.jpg”; // } // else // { // return site_url(“assets/uploads/no-product-image.jpg”); // } } }

Leave a Reply

Your email address will not be published. Required fields are marked *