本文整理汇总了PHP中Zend_Service_Amazon_S3::_makeRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Service_Amazon_S3::_makeRequest方法的具体用法?PHP Zend_Service_Amazon_S3::_makeRequest怎么用?PHP Zend_Service_Amazon_S3::_makeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Service_Amazon_S3
的用法示例。
在下文中一共展示了Zend_Service_Amazon_S3::_makeRequest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stream_read
/**
* Read from the stream
*
* http://bugs.php.net/21641 - stream_read() is always passed PHP's
* internal read buffer size (8192) no matter what is passed as $count
* parameter to fread().
*
* @param integer $count
* @return string
*/
public function stream_read($count)
{
if (!$this->_objectName) {
return false;
}
// make sure that count doesn't exceed object size
if ($count + $this->_position > $this->_objectSize) {
$count = $this->_objectSize - $this->_position;
}
$range_start = $this->_position;
$range_end = $this->_position + $count - 1;
// Only fetch more data from S3 if we haven't fetched any data yet (postion=0)
// OR, the range end position plus 1 is greater than the size of the current
// object buffer
if ($this->_objectBuffer === null || $range_end >= strlen($this->_objectBuffer)) {
$headers = array('Range' => "bytes={$range_start}-{$range_end}");
$response = $this->_s3->_makeRequest('GET', $this->_objectName, null, $headers);
if ($response->getStatus() == 206) {
// 206 Partial Content
$this->_objectBuffer .= $response->getBody();
}
}
$data = substr($this->_objectBuffer, $this->_position, $count);
$this->_position += strlen($data);
return $data;
}
示例2: stream_read
/**
* Read from the stream
*
* http://bugs.php.net/21641 - stream_read() is always passed PHP's
* internal read buffer size (8192) no matter what is passed as $count
* parameter to fread().
*
* @param integer $count
* @return string
*/
public function stream_read($count)
{
if (!$this->_objectName) {
return false;
}
// make sure that count doesn't exceed object size
if ($count + $this->_position > $this->_objectSize) {
$count = $this->_objectSize - $this->_position;
}
$range_start = $this->_position;
$range_end = $this->_position+$count;
// Only fetch more data from S3 if we haven't fetched any data yet (postion=0)
// OR, the range end position is greater than the size of the current object
// buffer AND if the range end position is less than or equal to the object's
// size returned by S3
if (($this->_position == 0) || (($range_end > strlen($this->_objectBuffer)) && ($range_end <= $this->_objectSize))) {
$headers = array(
'Range' => "bytes=$range_start-$range_end"
);
$response = $this->_s3->_makeRequest('GET', $this->_objectName, null, $headers);
if ($response->getStatus() == 206) { // 206 Partial Content
$this->_objectBuffer .= $response->getBody();
}
}
$data = substr($this->_objectBuffer, $this->_position, $count);
$this->_position += strlen($data);
return $data;
}
示例3: _makeRequest
/**
*
* @param <type> $method
* @param <type> $path
* @param <type> $params
* @param <type> $headers
* @param <type> $data
* @return <type>
*/
public function _makeRequest($method, $path = '', $params = null, $headers = array(), $data = null)
{
if ('PUT' == $method && $this->defaultAcl) {
$headers = array_merge(array(self::S3_ACL_HEADER => $this->defaultAcl), $headers);
}
return parent::_makeRequest($method, $path, $params, $headers, $data);
}
示例4: testVersionBucket
/**
* @see ZF-10219
*/
public function testVersionBucket()
{
$this->_amazon->createBucket($this->_bucket);
$response = $this->_amazon->_makeRequest('GET', $this->_bucket . '/?versions', array('versions' => ''));
$this->assertNotNull($response, 'The response for the ?versions is empty');
$xml = new SimpleXMLElement($response->getBody());
$this->assertEquals((string) $xml->Name, $this->_bucket, 'The bucket name in XML response is not valid');
}
示例5: stream_read
/**
* Read from the stream
*
* @param integer $count
* @return string
*/
public function stream_read($count)
{
if (!$this->_objectName) {
return false;
}
$range_start = $this->_position;
$range_end = $this->_position + $count;
// Only fetch more data from S3 if we haven't fetched any data yet (postion=0)
// OR, the range end position is greater than the size of the current object
// buffer AND if the range end position is less than or equal to the object's
// size returned by S3
if ($this->_position == 0 || $range_end > strlen($this->_objectBuffer) && $range_end <= $this->_objectSize) {
$headers = array('Range' => "{$range_start}-{$range_end}");
$response = $this->_s3->_makeRequest('GET', $this->_objectName, null, $headers);
if ($response->getStatus() == 200) {
$this->_objectBuffer .= $response->getBody();
}
}
$data = substr($this->_objectBuffer, $this->_position, $count);
$this->_position += strlen($data);
return $data;
}
示例6: setMeta
public function setMeta($userInfo, $shareInfo, $metaData, $errorHandle = false)
{
$config = self::$_registry->get("config");
if ($userInfo['id'] != $shareInfo['byUid']) {
throw new Exception("User is not the owner of the share.");
}
$changeData = array();
if ($errorHandle) {
foreach (self::$_editableMetadata as $what) {
if (empty($errorHandle[$what]) && $metaData[$what] != $shareInfo[$what]) {
$changeData[$what] = $metaData[$what];
}
}
} else {
$changeData = $metaData;
}
if (empty($changeData)) {
return false;
}
if (isset($changeData['filename'])) {
$s3 = new Zend_Service_Amazon_S3($config['services']['S3']['key'], $config['services']['S3']['secret']);
$bucketPlusObjectKeyPrefix = $config['services']['S3']['sharesBucket'] . "/" . $userInfo['alias'] . "/" . $shareInfo['id'] . "-" . $shareInfo['download_secret'] . "/";
$source = $bucketPlusObjectKeyPrefix . $shareInfo['filename'];
$destination = $bucketPlusObjectKeyPrefix . $changeData['filename'];
$meta = array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ, "x-amz-copy-source" => $source, "x-amz-metadata-directive" => "COPY");
$request = $s3->_makeRequest("PUT", $destination, null, $meta);
if ($request->getStatus() == 200) {
$filenameChanged = true;
}
}
if (isset($filenameChanged) && $filenameChanged) {
$removeFiles = Ml_Model_RemoveFiles::getInstance();
$removeFiles->addFileGc(array("share" => $shareInfo['id'], "byUid" => $shareInfo['byUid'], "download_secret" => $shareInfo['download_secret'], "filename" => $shareInfo['filename'], "alias" => $userInfo['alias']));
//Using delete from the S3 Zend class here doesn't work because of a bug
//is not working for some reason after the _makeRequest or other things I tried to COPY...
} else {
unset($changeData['filename']);
}
if (empty($changeData)) {
return false;
}
if (isset($changeData['description'])) {
$purifier = Ml_Model_HtmlPurifier::getInstance();
$changeData['description_filtered'] = $purifier->purify($changeData['description']);
}
$date = new Zend_Date();
$changeData['lastChange'] = $date->get("yyyy-MM-dd HH:mm:ss");
$this->_dbTable->update($changeData, $this->_dbAdapter->quoteInto("id = ?", $shareInfo['id']));
return array_merge($shareInfo, $changeData);
}