function verify_s3_etag($object_id, $expected_etag) { $url = s3_signed_object_url($object_id, time() + 300, 'HEAD'); $req = new HTTP_Request($url); $req->setMethod('HEAD'); $res = $req->sendRequest(); if (PEAR::isError($res)) { die_with_code(500, "{$res->message}\n{$q}\n"); } if ($req->getResponseCode() == 200) { return $req->getResponseHeader('etag') == $expected_etag; } return false; }
function s3_head($bucket, $object_id, $args = array()) { $defaults = array('expires' => time() + 300, 'method' => 'HEAD'); $args = array_merge($defaults, $args); $url = s3_signed_object_url($bucket, $object_id, $args); $rsp = http_head($url); return $rsp; }