/** * Test creating object with https * * ZF-7029 */ public function testCreateObjectSSL() { $this->_amazon->setEndpoint('https://s3.amazonaws.com'); $this->assertEquals('https://s3.amazonaws.com', $this->_amazon->getEndpoint()->getUri()); $this->_amazon->createBucket($this->_bucket); $this->_amazon->putObject($this->_bucket . "/zftest", "testdata"); $this->assertEquals("testdata", $this->_amazon->getObject($this->_bucket . "/zftest")); }
/** * Get a URI for a "stored" file. * * @see http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html#RESTAuthenticationQueryStringAuth * @param string $path * @return string URI */ public function getUri($path) { $endpoint = $this->_s3->getEndpoint(); $object = urlencode($this->_getObjectName($path)); $uri = "{$endpoint}/{$object}"; if ($expiration = $this->_getExpiration()) { $date = new Zend_Date(); $date->add($expiration, Zend_Date::MINUTE); $accessKeyId = $this->_options[self::AWS_KEY_OPTION]; $secretKey = $this->_options[self::AWS_SECRET_KEY_OPTION]; $expires = $date->getTimestamp(); $stringToSign = "GET\n\n\n{$expires}\n/{$object}"; $signature = base64_encode(Zend_Crypt_Hmac::compute($secretKey, 'sha1', utf8_encode($stringToSign), Zend_Crypt_Hmac::BINARY)); $query['AWSAccessKeyId'] = $accessKeyId; $query['Expires'] = $expires; $query['Signature'] = $signature; $queryString = http_build_query($query); $uri .= "?{$queryString}"; } return $uri; }