public function getMd5($path) { $v = null; $retries = 3; do { try { $v = $this->_s3->get_object_headers($this->getBucket(), $path); $retries = 0; } catch (Exception $e) { $this->_out->logWarning("retry S3::getMd5() for {$path}"); usleep(200); $retries--; } } while ($retries !== 0); if ($v === null || !array_key_exists('etag', $v->header)) { return false; } $md5 = str_replace('"', '', (string) $v->header['etag']); return $md5; }
<?php /* * v1. 22 June 2012 * * what this script does? * * print headers for an object in s3 bucket * */ require_once "sdk-1.5.7/sdk.class.php"; error_reporting(-1); $config = parse_ini_file("aws.ini"); $awsKey = $config["aws.key"]; $awsSecret = $config["aws.secret"]; $bucket = "test.indigloo"; $name = "garbage_bin_wallpaper.jpg"; $options = array("key" => $awsKey, "secret" => $awsSecret, "default_cache_config" => '', "certificate_authority" => true); $s3 = new AmazonS3($options); $exists = $s3->if_bucket_exists($bucket); if (!$exists) { printf("S3 bucket %s does not exists \n", $bucket); exit; } $response = $s3->get_object_headers($bucket, $name); print_r($response);