code
stringlengths
17
247k
docstring
stringlengths
30
30.3k
func_name
stringlengths
1
89
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
153
url
stringlengths
51
209
license
stringclasses
4 values
public function set_read_file($location) { $this->read_file = $location; $read_file_handle = fopen($location, 'r'); return $this->set_read_stream($read_file_handle); }
Set the file to read from while streaming up. @param string $location (Required) The readable location to read from. @return $this A reference to the current instance.
set_read_file
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function set_write_stream($resource) { $this->write_stream = $resource; return $this; }
Set the resource to write to while streaming down. @param resource $resource (Required) The writeable resource to write to. @return $this A reference to the current instance.
set_write_stream
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function set_write_file($location) { $this->write_file = $location; }
Set the file to write to while streaming down. @param string $location (Required) The writeable location to write to. @return $this A reference to the current instance.
set_write_file
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function set_proxy($proxy) { $proxy = parse_url($proxy); $proxy['user'] = isset($proxy['user']) ? $proxy['user'] : null; $proxy['pass'] = isset($proxy['pass']) ? $proxy['pass'] : null; $proxy['port'] = isset($proxy['port']) ? $proxy['port'] : null; $this->proxy = $proxy; return $this; }
Set the proxy to use for making requests. @param string $proxy (Required) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port` @return $this A reference to the current instance.
set_proxy
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function set_seek_position($position) { $this->seek_position = isset($position) ? (integer)$position : null; return $this; }
Set the intended starting seek position. @param integer $position (Required) The byte-position of the stream to begin reading from. @return $this A reference to the current instance.
set_seek_position
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function streaming_header_callback($curl_handle, $header_content) { $code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); if (isset($this->write_file) && intval($code) / 100 == 2 && !isset($this->write_file_handle)) { $this->write_file_handle = fopen($this->write_file, 'w'); $this->set_write_stream($this->write_file_handle); } $this->response_raw_headers .= $header_content; return strlen($header_content); }
A callback function that is invoked by cURL for streaming up. @param resource $curl_handle (Required) The cURL handle for the request. @param resource $header_content (Required) The header callback result. @return headers from a stream.
streaming_header_callback
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function register_streaming_read_callback($callback) { $this->registered_streaming_read_callback = $callback; return $this; }
Register a callback function to execute whenever a data stream is read from using <CFRequest::streaming_read_callback()>. The user-defined callback function should accept three arguments: <ul> <li><code>$curl_handle</code> - <code>resource</code> - Required - The cURL handle resource that represents the in-progress transfer.</li> <li><code>$file_handle</code> - <code>resource</code> - Required - The file handle resource that represents the file on the local file system.</li> <li><code>$length</code> - <code>integer</code> - Required - The length in kilobytes of the data chunk that was transferred.</li> </ul> @param string|array|function $callback (Required) The callback function is called by <php:call_user_func()>, so you can pass the following values: <ul> <li>The name of a global function to execute, passed as a string.</li> <li>A method to execute, passed as <code>array('ClassName', 'MethodName')</code>.</li> <li>An anonymous function (PHP 5.3+).</li></ul> @return $this A reference to the current instance.
register_streaming_read_callback
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function register_streaming_write_callback($callback) { $this->registered_streaming_write_callback = $callback; return $this; }
Register a callback function to execute whenever a data stream is written to using <CFRequest::streaming_write_callback()>. The user-defined callback function should accept two arguments: <ul> <li><code>$curl_handle</code> - <code>resource</code> - Required - The cURL handle resource that represents the in-progress transfer.</li> <li><code>$length</code> - <code>integer</code> - Required - The length in kilobytes of the data chunk that was transferred.</li> </ul> @param string|array|function $callback (Required) The callback function is called by <php:call_user_func()>, so you can pass the following values: <ul> <li>The name of a global function to execute, passed as a string.</li> <li>A method to execute, passed as <code>array('ClassName', 'MethodName')</code>.</li> <li>An anonymous function (PHP 5.3+).</li></ul> @return $this A reference to the current instance.
register_streaming_write_callback
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function streaming_read_callback($curl_handle, $file_handle, $length) { // Once we've sent as much as we're supposed to send... if ($this->read_stream_read >= $this->read_stream_size) { // Send EOF return ''; } // If we're at the beginning of an upload and need to seek... if ($this->read_stream_read == 0 && isset($this->seek_position) && $this->seek_position !== ftell($this->read_stream)) { if (fseek($this->read_stream, $this->seek_position) !== 0) { throw new RequestCore_Exception('The stream does not support seeking and is either not at the requested position or the position is unknown.'); } } $read = fread($this->read_stream, min($this->read_stream_size - $this->read_stream_read, $length)); // Remaining upload data or cURL's requested chunk size $this->read_stream_read += strlen($read); $out = $read === false ? '' : $read; // Execute callback function if ($this->registered_streaming_read_callback) { call_user_func($this->registered_streaming_read_callback, $curl_handle, $file_handle, $out); } return $out; }
A callback function that is invoked by cURL for streaming up. @param resource $curl_handle (Required) The cURL handle for the request. @param resource $file_handle (Required) The open file handle resource. @param integer $length (Required) The maximum number of bytes to read. @return binary Binary data from a stream.
streaming_read_callback
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function streaming_write_callback($curl_handle, $data) { $code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); if (intval($code) / 100 != 2) { $this->response_error_body .= $data; return strlen($data); } $length = strlen($data); $written_total = 0; $written_last = 0; while ($written_total < $length) { $written_last = fwrite($this->write_stream, substr($data, $written_total)); if ($written_last === false) { return $written_total; } $written_total += $written_last; } // Execute callback function if ($this->registered_streaming_write_callback) { call_user_func($this->registered_streaming_write_callback, $curl_handle, $written_total); } return $written_total; }
A callback function that is invoked by cURL for streaming down. @param resource $curl_handle (Required) The cURL handle for the request. @param binary $data (Required) The data to write. @return integer The number of bytes written.
streaming_write_callback
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function send_request($parse = false) { set_time_limit(0); $curl_handle = $this->prep_request(); $this->response = curl_exec($curl_handle); if ($this->response === false) { throw new RequestCore_Exception('cURL error: ' . curl_error($curl_handle) . ' (' . curl_errno($curl_handle) . ')'); } $parsed_response = $this->process_response($curl_handle, $this->response); curl_close($curl_handle); unset($curl_handle); if ($parse) { return $parsed_response; } return $this->response; }
Send the request, calling necessary utility functions to update built-in properties. @param boolean $parse (Optional) Whether to parse the response with ResponseCore or not. @return string The resulting unparsed data from the request.
send_request
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function get_response_header($header = null) { if ($header) { return $this->response_headers[strtolower($header)]; } return $this->response_headers; }
Get the HTTP response headers from the request. @param string $header (Optional) A specific header value to return. Defaults to all headers. @return string|array All or selected header values.
get_response_header
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function get_response_body() { return $this->response_body; }
Get the HTTP response body from the request. @return string The response body.
get_response_body
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public function get_response_code() { return $this->response_code; }
Get the HTTP response code from the request. @return string The HTTP response code.
get_response_code
php
aliyun/aliyun-oss-php-sdk
src/OSS/Http/RequestCore.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Http/RequestCore.php
MIT
public static function getMimetype($name) { $parts = explode('.', $name); if (count($parts) > 1) { $ext = strtolower(end($parts)); if (isset(self::$mime_types[$ext])) { return self::$mime_types[$ext]; } } return null; }
Get the content-type value of http header from the file's extension name. @param string $name Default file extension name. @return string content-type
getMimetype
php
aliyun/aliyun-oss-php-sdk
src/OSS/Core/MimeTypes.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Core/MimeTypes.php
MIT
public static function sReplace($subject) { $search = array('<', '>', '&', '\'', '"'); $replace = array('&lt;', '&gt;', '&amp;', '&apos;', '&quot;'); return str_replace($search, $replace, $subject); }
Html encoding '<', '>', '&', '\', '"' in subject parameter. @param string $subject @return string
sReplace
php
aliyun/aliyun-oss-php-sdk
src/OSS/Core/OssUtil.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Core/OssUtil.php
MIT
public static function chkChinese($str) { return preg_match('/[\x80-\xff]./', $str); }
Check whether the string includes any chinese character @param $str @return int
chkChinese
php
aliyun/aliyun-oss-php-sdk
src/OSS/Core/OssUtil.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Core/OssUtil.php
MIT
public static function isGb2312($str) { for ($i = 0; $i < strlen($str); $i++) { $v = ord($str[$i]); if ($v > 127) { if (($v >= 228) && ($v <= 233)) { if (($i + 2) >= (strlen($str) - 1)) return true; // not enough characters $v1 = ord($str[$i + 1]); $v2 = ord($str[$i + 2]); if (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) return false; else return true; } } } return false; }
Checks if the string is encoded by GB2312. @param string $str @return boolean false UTF-8 encoding TRUE GB2312 encoding
isGb2312
php
aliyun/aliyun-oss-php-sdk
src/OSS/Core/OssUtil.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Core/OssUtil.php
MIT
public static function checkChar($str, $gbk = true) { for ($i = 0; $i < strlen($str); $i++) { $v = ord($str[$i]); if ($v > 127) { if (($v >= 228) && ($v <= 233)) { if (($i + 2) >= (strlen($str) - 1)) return $gbk ? true : FALSE; // not enough characters $v1 = ord($str[$i + 1]); $v2 = ord($str[$i + 2]); if ($gbk) { return (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) ? FALSE : TRUE;//GBK } else { return (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) ? TRUE : FALSE; } } } } return $gbk ? TRUE : FALSE; }
Checks if the string is encoded by GBK @param string $str @param boolean $gbk @return boolean
checkChar
php
aliyun/aliyun-oss-php-sdk
src/OSS/Core/OssUtil.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Core/OssUtil.php
MIT
public static function validateBucket($bucket) { $pattern = '/^[a-z0-9][a-z0-9-]{2,62}$/'; if (!preg_match($pattern, $bucket)) { return false; } return true; }
Checks if the bucket name is valid bucket naming rules 1. Can only include lowercase letters, numbers, or dashes 2. Must start and end with lowercase letters or numbers 3. Must be within a length from 3 to 63 bytes. @param string $bucket Bucket name @return boolean
validateBucket
php
aliyun/aliyun-oss-php-sdk
src/OSS/Core/OssUtil.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Core/OssUtil.php
MIT
public static function validateObject($object) { $pattern = '/^.{1,1023}$/'; if (!preg_match($pattern, $object) || self::startsWith($object, '/') || self::startsWith($object, '\\') ) { return false; } return true; }
Checks if object name is valid object naming rules: 1. Must be within a length from 1 to 1023 bytes 2. Cannot start with '/' or '\\'. 3. Must be encoded in UTF-8. @param string $object Object名称 @return boolean
validateObject
php
aliyun/aliyun-oss-php-sdk
src/OSS/Core/OssUtil.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Core/OssUtil.php
MIT
public static function startsWith($str, $findMe) { if (strpos($str, $findMe) === 0) { return true; } else { return false; } }
Checks if $str starts with $findMe @param string $str @param string $findMe @return bool
startsWith
php
aliyun/aliyun-oss-php-sdk
src/OSS/Core/OssUtil.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Core/OssUtil.php
MIT
public function serializeToXml() { $xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><Tagging></Tagging>'); $xmlTagSet = $xml->addChild('TagSet'); foreach ($this->tags as $tag) { $xmlTag = $xmlTagSet->addChild('Tag'); $xmlTag->addChild('Key', strval($tag->getKey())); $xmlTag->addChild('Value', strval($tag->getValue())); } return $xml->asXML(); } public function __toString() { return $this->serializeToXml(); } /** * Tag list * * @var Tag[] */ private $tags = array(); }
Serialize the object into xml string. @return string
serializeToXml
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/TaggingConfig.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/TaggingConfig.php
MIT
public function __construct($key, $versionId, $deleteMarker, $deleteMarkerVersionId) { $this->key = $key; $this->versionId = $versionId; $this->deleteMarker = $deleteMarker; $this->deleteMarkerVersionId = $deleteMarkerVersionId; }
DeletedObjectInfo constructor. @param string $key @param string $versionId @param string $deleteMarker @param string $deleteMarkerVersionId
__construct
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/DeletedObjectInfo.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/DeletedObjectInfo.php
MIT
public function parseFromXml($strXml) { $xml = simplexml_load_string($strXml); if (isset($xml->Bucket) ) { $this->bucket = strval($xml->Bucket); } if (isset($xml->Cname) ) { $this->cname = strval($xml->Cname); } if (isset($xml->Token) ) { $this->token = strval($xml->Token); } if (isset($xml->ExpireTime) ) { $this->expireTime = strval($xml->ExpireTime); } }
Parse cname token from the xml. @param string $strXml @throws OssException @return null
parseFromXml
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/CnameTokenInfo.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/CnameTokenInfo.php
MIT
public function __construct($key, $versionId, $lastModified, $eTag, $type, $size, $storageClass, $isLatest) { $this->key = $key; $this->versionId = $versionId; $this->lastModified = $lastModified; $this->eTag = $eTag; $this->type = $type; $this->size = $size; $this->storageClass = $storageClass; $this->isLatest = $isLatest; }
ObjectVersionInfo constructor. @param string $key @param string $lastModified @param string $eTag @param string $type @param string $size @param string $storageClass @param string $isLatest
__construct
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/ObjectVersionInfo.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/ObjectVersionInfo.php
MIT
public function __construct($payer = null) { $this->payer = $payer; }
RequestPaymentConfig constructor. @param null $payer
__construct
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/RequestPaymentConfig.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/RequestPaymentConfig.php
MIT
public function parseFromXml($strXml) { $xml = simplexml_load_string($strXml); if (isset($xml->Payer)) { $this->payer = strval($xml->Payer); } }
Parse ServerSideEncryptionConfig from the xml. @param string $strXml @throws OssException @return null
parseFromXml
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/RequestPaymentConfig.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/RequestPaymentConfig.php
MIT
public function parseFromXml($strXml) { throw new OssException("Not implemented."); }
Parse ExtendWormConfig from the xml. @param string $strXml @throws OssException @return null
parseFromXml
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/ExtendWormConfig.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/ExtendWormConfig.php
MIT
public function __construct($day = null) { $this->day = $day; }
InitiateWormConfig constructor. @param null $day
__construct
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/InitiateWormConfig.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/InitiateWormConfig.php
MIT
public function appendToXml(&$xmlRule) { $xmlAction = $xmlRule->addChild($this->action); $xmlAction->addChild($this->timeSpec, $this->timeValue); }
Use appendToXml to insert actions into xml. @param \SimpleXMLElement $xmlRule
appendToXml
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/LifecycleAction.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/LifecycleAction.php
MIT
public function parseFromXml($strXml) { $xml = simplexml_load_string($strXml); if (isset($xml->Status)) { $this->status = strval($xml->Status); } }
Parse VersioningConfig from the xml. @param string $strXml @throws OssException @return null
parseFromXml
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/VersioningConfig.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/VersioningConfig.php
MIT
public function parseFromXml($strXml) { $xml = simplexml_load_string($strXml); if (isset($xml->Enabled)) { $this->enabled = (strval($xml->Enabled) === 'TRUE' || strval($xml->Enabled) === 'true') ? true : false; } }
Parse TransferAccelerationConfig from the xml. @param string $strXml @throws OssException @return null
parseFromXml
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/TransferAccelerationConfig.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/TransferAccelerationConfig.php
MIT
public function parseFromXml($strXml) { $xml = simplexml_load_string($strXml); if (isset($xml->WormId)) { $this->wormId = strval($xml->WormId); } if (isset($xml->State)) { $this->state = strval($xml->State); } if (isset($xml->RetentionPeriodInDays)) { $this->day = intval($xml->RetentionPeriodInDays); } if (isset($xml->CreationDate)) { $this->creationDate = strval($xml->CreationDate); } }
Parse WormConfig from the xml. @param string $strXml @throws OssException @return null
parseFromXml
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/WormConfig.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/WormConfig.php
MIT
public function __construct($bucket, $keyMarker, $uploadIdMarker, $nextKeyMarker, $nextUploadIdMarker, $delimiter, $prefix, $maxUploads, $isTruncated, array $uploads) { $this->bucket = $bucket; $this->keyMarker = $keyMarker; $this->uploadIdMarker = $uploadIdMarker; $this->nextKeyMarker = $nextKeyMarker; $this->nextUploadIdMarker = $nextUploadIdMarker; $this->delimiter = $delimiter; $this->prefix = $prefix; $this->maxUploads = $maxUploads; $this->isTruncated = $isTruncated; $this->uploads = $uploads; }
ListMultipartUploadInfo constructor. @param string $bucket @param string $keyMarker @param string $uploadIdMarker @param string $nextKeyMarker @param string $nextUploadIdMarker @param string $delimiter @param string $prefix @param int $maxUploads @param string $isTruncated @param array $uploads
__construct
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/ListMultipartUploadInfo.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/ListMultipartUploadInfo.php
MIT
public function __construct($bucketName, $prefix, $keyMarker, $nextKeyMarker, $versionIdMarker, $nextVersionIdMarker , $maxKeys, $delimiter, $isTruncated , array $objectversionList, array $deleteMarkerList, array $prefixList) { $this->bucketName = $bucketName; $this->prefix = $prefix; $this->keyMarker = $keyMarker; $this->nextKeyMarker = $nextKeyMarker; $this->versionIdMarker = $versionIdMarker; $this->nextVersionIdMarker = $nextVersionIdMarker; $this->maxKeys = $maxKeys; $this->delimiter = $delimiter; $this->isTruncated = $isTruncated; $this->objectVersionList = $objectversionList; $this->deleteMarkerList = $deleteMarkerList; $this->prefixList = $prefixList; }
ObjectVersionListInfo constructor. @param string $bucketName @param string $prefix @param string $keyMarker @param string $nextKeyMarker @param string $versionIdMarker @param string $nextVersionIdMarker @param string $maxKeys @param string $delimiter @param null|string $isTruncated @param array $objectversionList @param array $deleteMarkerList @param array $prefixList
__construct
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/ObjectVersionListInfo.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/ObjectVersionListInfo.php
MIT
public function getObjectVersionList() { return $this->objectVersionList; }
Get the ObjectVersionInfo list. @return ObjectVersionInfo[]
getObjectVersionList
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/ObjectVersionListInfo.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/ObjectVersionListInfo.php
MIT
public function getDeleteMarkerList() { return $this->deleteMarkerList; }
Get the DeleteMarkerInfo list. @return DeleteMarkerInfo[]
getDeleteMarkerList
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/ObjectVersionListInfo.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/ObjectVersionListInfo.php
MIT
public function __construct($sseAlgorithm = null, $kmsMasterKeyID = null) { $this->sseAlgorithm = $sseAlgorithm; $this->kmsMasterKeyID = $kmsMasterKeyID; }
ServerSideEncryptionConfig constructor. @param null $sseAlgorithm @param null $kmsMasterKeyID
__construct
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/ServerSideEncryptionConfig.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/ServerSideEncryptionConfig.php
MIT
public function __construct($storageCapacity) { $this->storageCapacity = $storageCapacity; }
StorageCapacityConfig constructor. @param int $storageCapacity
__construct
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/StorageCapacityConfig.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/StorageCapacityConfig.php
MIT
public function parseFromXmlNode($xml) { if (isset($xml->Location)) { $this->location = strval($xml->Location); } if (isset($xml->Name)) { $this->name = strval($xml->Name); } if (isset($xml->CreationDate)) { $this->createDate = strval($xml->CreationDate); } if (isset($xml->StorageClass)) { $this->storageClass = strval($xml->StorageClass); } if (isset($xml->ExtranetEndpoint)) { $this->extranetEndpoint = strval($xml->ExtranetEndpoint); } if (isset($xml->IntranetEndpoint)) { $this->intranetEndpoint = strval($xml->IntranetEndpoint); } if (isset($xml->IntranetEndpoint)) { $this->intranetEndpoint = strval($xml->IntranetEndpoint); } if (isset($xml->Region)) { $this->region = strval($xml->Region); } }
Parse bucket information from node. @param xml $xml @throws OssException @return null
parseFromXmlNode
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/BucketInfo.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/BucketInfo.php
MIT
public function getInfrequentAccessRealStorage() { return $this->infrequentAccessRealStorage; }
Get infrequent access real storage @return int
getInfrequentAccessRealStorage
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/BucketStat.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/BucketStat.php
MIT
public function getInfrequentAccessObjectCount() { return $this->infrequentAccessObjectCount; }
Get infrequent access object count @return int
getInfrequentAccessObjectCount
php
aliyun/aliyun-oss-php-sdk
src/OSS/Model/BucketStat.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Model/BucketStat.php
MIT
protected function isResponseOk() { $status = $this->rawResponse->status; if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { return true; } return false; }
Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, 404 is also considered a valid response @return bool
isResponseOk
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/GetRefererResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/GetRefererResult.php
MIT
protected function parseDataFromResponse() { $content = $this->rawResponse->body; $config = new RequestPaymentConfig(); $config->parseFromXml($content); return $config->getPayer(); }
Parse the RequestPaymentConfig object from the response @return RequestPaymentConfig
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/GetBucketRequestPaymentResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/GetBucketRequestPaymentResult.php
MIT
protected function parseDataFromResponse() { $content = $this->rawResponse->body; $config = new LifecycleConfig(); $config->parseFromXml($content); return $config; }
Parse the LifecycleConfig object from the response @return LifecycleConfig
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/GetLifecycleResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/GetLifecycleResult.php
MIT
protected function parseDataFromResponse() { $xml = new \SimpleXMLElement($this->rawResponse->body); $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; $objectList = $this->parseObjectList($xml, $encodingType); $prefixList = $this->parsePrefixList($xml, $encodingType); $bucketName = isset($xml->Name) ? strval($xml->Name) : ""; $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; $prefix = OssUtil::decodeKey($prefix, $encodingType); $marker = isset($xml->Marker) ? strval($xml->Marker) : ""; $marker = OssUtil::decodeKey($marker, $encodingType); $maxKeys = isset($xml->MaxKeys) ? intval($xml->MaxKeys) : 0; $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; $delimiter = OssUtil::decodeKey($delimiter, $encodingType); $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; $nextMarker = isset($xml->NextMarker) ? strval($xml->NextMarker) : ""; $nextMarker = OssUtil::decodeKey($nextMarker, $encodingType); return new ObjectListInfo($bucketName, $prefix, $marker, $nextMarker, $maxKeys, $delimiter, $isTruncated, $objectList, $prefixList); }
Parse the xml data returned by the ListObjects interface @return ObjectListInfo @throws OssException
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/ListObjectsResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/ListObjectsResult.php
MIT
public function getData() { return $this->parsedData; }
Get the returned data, different request returns the data format is different $return mixed
getData
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/Result.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/Result.php
MIT
public function isOK() { return $this->isOk; }
Whether the operation is successful @return mixed
isOK
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/Result.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/Result.php
MIT
private function retrieveErrorMessage($body) { if (empty($body) || false === strpos($body, '<?xml')) { return ''; } $flag = false; try { $xml = simplexml_load_string($body); if (isset($xml->Message)) { return strval($xml->Message); } $flag = true; } catch (\Exception $e) { $flag = true; } if ($flag === true) { $start = strpos($body, '<Message>'); if ($start === false) { return ''; } $start += 9; $end = strpos($body, '</Message>', $start); if ($end === false) { return ''; } return substr($body, $start, $end - $start); } return ''; }
Try to get the error message from body @param $body @return string
retrieveErrorMessage
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/Result.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/Result.php
MIT
private function retrieveErrorCode($body) { if (empty($body) || false === strpos($body, '<?xml')) { return ''; } $flag = false; try { $xml = simplexml_load_string($body); if (isset($xml->Code)) { return strval($xml->Code); } $flag = true; } catch (\Exception $e) { $flag = true; } if ($flag === true) { $start = strpos($body, '<Code>'); if ($start === false) { return ''; } $start += 6; $end = strpos($body, '</Code>', $start); if ($end === false) { return ''; } return substr($body, $start, $end - $start); } return ''; }
Try to get the error Code from body @param $body @return string
retrieveErrorCode
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/Result.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/Result.php
MIT
protected function isResponseOk() { $status = $this->rawResponse->status; if ((int)(intval($status) / 100) == 2) { return true; } return false; }
Judging from the return http status code, [200-299] that is OK @return bool
isResponseOk
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/Result.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/Result.php
MIT
public function getRawResponse() { return $this->rawResponse; }
Return the original return data @return ResponseCore
getRawResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/Result.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/Result.php
MIT
protected function parseDataFromResponse() { $header = $this->rawResponse->header; if (isset($header["x-oss-next-append-position"])) { return intval($header["x-oss-next-append-position"]); } throw new OssException("cannot get next-append-position"); }
Get the value of next-append-position from append's response headers @return int @throws OssException
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/AppendResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/AppendResult.php
MIT
protected function parseDataFromResponse() { $content = $this->rawResponse->body; $xml = simplexml_load_string($content); if (isset($xml->UploadId)) { return strval($xml->UploadId); } throw new OssException("cannot get UploadId"); }
Get uploadId in result and return @throws OssException @return string
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/InitiateMultipartUploadResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/InitiateMultipartUploadResult.php
MIT
protected function parseDataFromResponse() { $xml = new \SimpleXMLElement($this->rawResponse->body); $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; $objectList = $this->parseObjectList($xml, $encodingType); $prefixList = $this->parsePrefixList($xml, $encodingType); $bucketName = isset($xml->Name) ? strval($xml->Name) : ""; $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; $prefix = OssUtil::decodeKey($prefix, $encodingType); $maxKeys = isset($xml->MaxKeys) ? intval($xml->MaxKeys) : 0; $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; $delimiter = OssUtil::decodeKey($delimiter, $encodingType); $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; $continuationToken = isset($xml->ContinuationToken) ? strval($xml->ContinuationToken) : ""; $nextContinuationToken = isset($xml->NextContinuationToken) ? strval($xml->NextContinuationToken) : ""; $startAfter = isset($xml->StartAfter) ? strval($xml->StartAfter) : ""; $startAfter = OssUtil::decodeKey($startAfter, $encodingType); $keyCount = isset($xml->KeyCount) ? intval($xml->KeyCount) : 0; return new ObjectListInfoV2($bucketName, $prefix, $maxKeys, $delimiter, $isTruncated, $objectList, $prefixList, $continuationToken, $nextContinuationToken, $startAfter, $keyCount); }
Parse the xml data returned by the ListObjectsV2 interface @return ObjectListInfoV2 @throws OssException
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/ListObjectsV2Result.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/ListObjectsV2Result.php
MIT
protected function parseDataFromResponse() { return empty($this->rawResponse->header) ? array() : $this->rawResponse->header; }
The returned ResponseCore header is used as the return data @return array
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/HeaderResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/HeaderResult.php
MIT
protected function parseDataFromResponse() { $header = $this->rawResponse->header; if (isset($header["x-oss-worm-id"])) { return strval($header["x-oss-worm-id"]); } throw new OssException("cannot get worm-id"); }
Get the value of worm-id from response headers @return int @throws OssException
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/InitiateBucketWormResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/InitiateBucketWormResult.php
MIT
protected function parseDataFromResponse() { $content = $this->rawResponse->body; $config = new ServerSideEncryptionConfig(); $config->parseFromXml($content); return $config; }
Parse the ServerSideEncryptionConfig object from the response @return ServerSideEncryptionConfig
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/GetBucketEncryptionResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/GetBucketEncryptionResult.php
MIT
protected function parseDataFromResponse() { $xml = simplexml_load_string($this->rawResponse->body); $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; $objectVersionList = $this->parseObjecVersionList($xml, $encodingType); $deleteMarkerList = $this->parseDeleteMarkerList($xml, $encodingType); $prefixList = $this->parsePrefixList($xml, $encodingType); $bucketName = isset($xml->Name) ? strval($xml->Name) : ""; $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; $prefix = OssUtil::decodeKey($prefix, $encodingType); $keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : ""; $keyMarker = OssUtil::decodeKey($keyMarker, $encodingType); $nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : ""; $nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType); $versionIdMarker = isset($xml->VersionIdMarker) ? strval($xml->VersionIdMarker) : ""; $nextVersionIdMarker = isset($xml->NextVersionIdMarker) ? strval($xml->NextVersionIdMarker) : ""; $maxKeys = isset($xml->MaxKeys) ? intval($xml->MaxKeys) : 0; $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; $delimiter = OssUtil::decodeKey($delimiter, $encodingType); $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; return new ObjectVersionListInfo($bucketName, $prefix, $keyMarker, $nextKeyMarker, $versionIdMarker, $nextVersionIdMarker, $maxKeys, $delimiter, $isTruncated, $objectVersionList, $deleteMarkerList, $prefixList); }
Parse the xml data returned by the ListObjectVersions interface @return ObjectVersionListInfo @throws OssException
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/ListObjectVersionsResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/ListObjectVersionsResult.php
MIT
protected function parseDataFromResponse() { $content = $this->rawResponse->body; $config = new TaggingConfig(); $config->parseFromXml($content); return $config; }
Parse the TaggingConfig object from the response @return TaggingConfig
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/GetBucketTagsResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/GetBucketTagsResult.php
MIT
protected function parseDataFromResponse() { $content = $this->rawResponse->body; $config = new VersioningConfig(); $config->parseFromXml($content); return $config->getStatus(); }
Parse the VersioningConfig object from the response @return VersioningConfig
parseDataFromResponse
php
aliyun/aliyun-oss-php-sdk
src/OSS/Result/GetBucketVersioningResult.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/src/OSS/Result/GetBucketVersioningResult.php
MIT
function putBucketWebsite($ossClient, $bucket) { $websiteConfig = new WebsiteConfig("index.html", "error.html"); try { $ossClient->putBucketWebsite($bucket, $websiteConfig); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Sets bucket static website configuration @param $ossClient OssClient @param $bucket string bucket name @return null
putBucketWebsite
php
aliyun/aliyun-oss-php-sdk
samples/BucketWebsite.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketWebsite.php
MIT
function getBucketWebsite($ossClient, $bucket) { $websiteConfig = null; try { $websiteConfig = $ossClient->getBucketWebsite($bucket); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); print($websiteConfig->serializeToXml() . "\n"); }
Get bucket static website configuration @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
getBucketWebsite
php
aliyun/aliyun-oss-php-sdk
samples/BucketWebsite.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketWebsite.php
MIT
function deleteBucketWebsite($ossClient, $bucket) { try { $ossClient->deleteBucketWebsite($bucket); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Delete bucket static website configuration @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
deleteBucketWebsite
php
aliyun/aliyun-oss-php-sdk
samples/BucketWebsite.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketWebsite.php
MIT
function putBucketReferer($ossClient, $bucket) { $refererConfig = new RefererConfig(); $refererConfig->setAllowEmptyReferer(true); $refererConfig->addReferer("www.aliiyun.com"); $refererConfig->addReferer("www.aliiyuncs.com"); try { $ossClient->putBucketReferer($bucket, $refererConfig); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Set bucket referer configuration @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
putBucketReferer
php
aliyun/aliyun-oss-php-sdk
samples/BucketReferer.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketReferer.php
MIT
function getBucketReferer($ossClient, $bucket) { $refererConfig = null; try { $refererConfig = $ossClient->getBucketReferer($bucket); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); print($refererConfig->serializeToXml() . "\n"); }
Get bucket referer configuration @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
getBucketReferer
php
aliyun/aliyun-oss-php-sdk
samples/BucketReferer.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketReferer.php
MIT
function deleteBucketReferer($ossClient, $bucket) { $refererConfig = new RefererConfig(); try { $ossClient->putBucketReferer($bucket, $refererConfig); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Delete bucket referer configuration Referer whitelist cannot be directly deleted. So use a empty one to overwrite it. @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
deleteBucketReferer
php
aliyun/aliyun-oss-php-sdk
samples/BucketReferer.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketReferer.php
MIT
function putObject($ossClient, $bucket) { $object = "oss-php-sdk-test/upload-test-object-name.txt"; $content = file_get_contents(__FILE__); $options = array(); try { $ossClient->putObject($bucket, $object, $content, $options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Upload in-memory data to oss Simple upload---upload specified in-memory data to an OSS object @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
putObject
php
aliyun/aliyun-oss-php-sdk
samples/Object.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Object.php
MIT
function listAllObjects($ossClient, $bucket) { // Create dir/obj 'folder' and put some files into it. for ($i = 0; $i < 100; $i += 1) { $ossClient->putObject($bucket, "dir/obj" . strval($i), "hi"); $ossClient->createObjectDir($bucket, "dir/obj" . strval($i)); } $prefix = 'dir/'; $delimiter = '/'; $nextMarker = ''; $maxkeys = 30; while (true) { $options = array( 'delimiter' => $delimiter, 'prefix' => $prefix, 'max-keys' => $maxkeys, 'marker' => $nextMarker, ); var_dump($options); try { $listObjectInfo = $ossClient->listObjects($bucket, $options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } // Get the nextMarker, and it would be used as the next call's marker parameter to resume from the last call $nextMarker = $listObjectInfo->getNextMarker(); $listObject = $listObjectInfo->getObjectList(); $listPrefix = $listObjectInfo->getPrefixList(); var_dump(count($listObject)); var_dump(count($listPrefix)); if ($nextMarker === '') { break; } } }
Lists all folders and files under the bucket. Use nextMarker repeatedly to get all objects. @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
listAllObjects
php
aliyun/aliyun-oss-php-sdk
samples/Object.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Object.php
MIT
function getObjectToLocalFile($ossClient, $bucket) { $object = "oss-php-sdk-test/upload-test-object-name.txt"; $localfile = "upload-test-object-name.txt"; $options = array( OssClient::OSS_FILE_DOWNLOAD => $localfile, ); try { $ossClient->getObject($bucket, $object, $options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK, please check localfile: 'upload-test-object-name.txt'" . "\n"); if (file_get_contents($localfile) === file_get_contents(__FILE__)) { print(__FUNCTION__ . ": FileContent checked OK" . "\n"); } else { print(__FUNCTION__ . ": FileContent checked FAILED" . "\n"); } if (file_exists($localfile)) { unlink($localfile); } }
Get_object_to_local_file Get object Download object to a specified file. @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
getObjectToLocalFile
php
aliyun/aliyun-oss-php-sdk
samples/Object.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Object.php
MIT
function copyObject($ossClient, $bucket) { $fromBucket = $bucket; $fromObject = "oss-php-sdk-test/upload-test-object-name.txt"; $toBucket = $bucket; $toObject = $fromObject . '.copy'; $options = array(); try { $ossClient->copyObject($fromBucket, $fromObject, $toBucket, $toObject, $options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Copy object When the source object is same as the target one, copy operation will just update the metadata. @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
copyObject
php
aliyun/aliyun-oss-php-sdk
samples/Object.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Object.php
MIT
function modifyMetaForObject($ossClient, $bucket) { $fromBucket = $bucket; $fromObject = "oss-php-sdk-test/upload-test-object-name.txt"; $toBucket = $bucket; $toObject = $fromObject; $copyOptions = array( OssClient::OSS_HEADERS => array( 'Cache-Control' => 'max-age=60', 'Content-Disposition' => 'attachment; filename="xxxxxx"', ), ); try { $ossClient->copyObject($fromBucket, $fromObject, $toBucket, $toObject, $copyOptions); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Update Object Meta it leverages the feature of copyObject: when the source object is just the target object, the metadata could be updated via copy @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
modifyMetaForObject
php
aliyun/aliyun-oss-php-sdk
samples/Object.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Object.php
MIT
function getObjectMeta($ossClient, $bucket) { $object = "oss-php-sdk-test/upload-test-object-name.txt"; try { $objectMeta = $ossClient->getObjectMeta($bucket, $object); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); if (isset($objectMeta[strtolower('Content-Disposition')]) && 'attachment; filename="xxxxxx"' === $objectMeta[strtolower('Content-Disposition')] ) { print(__FUNCTION__ . ": ObjectMeta checked OK" . "\n"); } else { print(__FUNCTION__ . ": ObjectMeta checked FAILED" . "\n"); } }
Get object meta, that is, getObjectMeta @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
getObjectMeta
php
aliyun/aliyun-oss-php-sdk
samples/Object.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Object.php
MIT
function deleteObjects($ossClient, $bucket) { $objects = array(); $objects[] = "oss-php-sdk-test/upload-test-object-name.txt"; $objects[] = "oss-php-sdk-test/upload-test-object-name.txt.copy"; try { $ossClient->deleteObjects($bucket, $objects); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Delete multiple objects in batch @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
deleteObjects
php
aliyun/aliyun-oss-php-sdk
samples/Object.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Object.php
MIT
function doesObjectExist($ossClient, $bucket) { $object = "oss-php-sdk-test/upload-test-object-name.txt"; try { $exist = $ossClient->doesObjectExist($bucket, $object); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); var_dump($exist); }
Check whether an object exists @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
doesObjectExist
php
aliyun/aliyun-oss-php-sdk
samples/Object.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Object.php
MIT
function multiuploadFile($ossClient, $bucket) { $object = "test/multipart-test.txt"; $file = __FILE__; $options = array(); try { $ossClient->multiuploadFile($bucket, $object, $file, $options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Upload files using multipart upload @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
multiuploadFile
php
aliyun/aliyun-oss-php-sdk
samples/MultipartUpload.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/MultipartUpload.php
MIT
function getSignedUrlForGettingObject($ossClient, $bucket) { $object = "test/test-signature-test-upload-and-download.txt"; $timeout = 3600; try { $signedUrl = $ossClient->signUrl($bucket, $object, $timeout); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n"); /** * Use similar code to access the object by url, or use browser to access the object. */ $request = new RequestCore($signedUrl); $request->set_method('GET'); $request->add_header('Content-Type', ''); $request->send_request(); $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); if ($res->isOK()) { print(__FUNCTION__ . ": OK" . "\n"); } else { print(__FUNCTION__ . ": FAILED" . "\n"); }; }
Generate the signed url for getObject() to control read accesses under private privilege @param $ossClient OssClient OssClient instance @param $bucket string bucket name @return null
getSignedUrlForGettingObject
php
aliyun/aliyun-oss-php-sdk
samples/Signature.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Signature.php
MIT
function getSignedUrlForPuttingObject($ossClient, $bucket) { $object = "test/test-signature-test-upload-and-download.txt"; $timeout = 3600; $options = NULL; try { $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT"); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n"); $content = file_get_contents(__FILE__); $request = new RequestCore($signedUrl); $request->set_method('PUT'); $request->add_header('Content-Type', ''); $request->add_header('Content-Length', strlen($content)); $request->set_body($content); $request->send_request(); $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); if ($res->isOK()) { print(__FUNCTION__ . ": OK" . "\n"); } else { print(__FUNCTION__ . ": FAILED" . "\n"); }; }
Generate the signed url for PutObject to control write accesses under private privilege. @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null @throws OssException
getSignedUrlForPuttingObject
php
aliyun/aliyun-oss-php-sdk
samples/Signature.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Signature.php
MIT
function getSignedUrlForPuttingObjectFromFile($ossClient, $bucket) { $file = __FILE__; $object = "test/test-signature-test-upload-and-download.txt"; $timeout = 3600; $options = array('Content-Type' => 'txt'); try { $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n"); $request = new RequestCore($signedUrl); $request->set_method('PUT'); $request->add_header('Content-Type', 'txt'); $request->set_read_file($file); $request->set_read_stream_size(sprintf('%u',filesize($file))); $request->send_request(); $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); if ($res->isOK()) { print(__FUNCTION__ . ": OK" . "\n"); } else { print(__FUNCTION__ . ": FAILED" . "\n"); }; }
Generate the signed url for PutObject's signed url. User could use the signed url to upload file directly. @param OssClient $ossClient OssClient instance @param string $bucket bucket name @throws OssException
getSignedUrlForPuttingObjectFromFile
php
aliyun/aliyun-oss-php-sdk
samples/Signature.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Signature.php
MIT
function createBucket($ossClient, $bucket) { try { $ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Create a new bucket acl indicates the access permission of a bucket, including: private, public-read-only/private-read-write, and public read-write. Private indicates that only the bucket owner or authorized users can access the data.. The three permissions are separately defined by (OssClient::OSS_ACL_TYPE_PRIVATE,OssClient::OSS_ACL_TYPE_PUBLIC_READ, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE) @param OssClient $ossClient OssClient instance @param string $bucket Name of the bucket to create @return null
createBucket
php
aliyun/aliyun-oss-php-sdk
samples/Bucket.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Bucket.php
MIT
function doesBucketExist($ossClient, $bucket) { try { $res = $ossClient->doesBucketExist($bucket); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } if ($res === true) { print(__FUNCTION__ . ": OK" . "\n"); } else { print(__FUNCTION__ . ": FAILED" . "\n"); } }
Check whether a bucket exists. @param OssClient $ossClient OssClient instance @param string $bucket bucket name
doesBucketExist
php
aliyun/aliyun-oss-php-sdk
samples/Bucket.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Bucket.php
MIT
function deleteBucket($ossClient, $bucket) { try { $ossClient->deleteBucket($bucket); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Delete a bucket. If the bucket is not empty, the deletion fails. A bucket which is not empty indicates that it does not contain any objects or parts that are not completely uploaded during multipart upload @param OssClient $ossClient OssClient instance @param string $bucket Name of the bucket to delete @return null
deleteBucket
php
aliyun/aliyun-oss-php-sdk
samples/Bucket.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Bucket.php
MIT
function abortBucketWorm($ossClient, $bucket) { try { $ossClient->abortBucketWorm($bucket); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Cancel an unlocked compliance retention policy @param OssClient $ossClient OssClient instance @param string $bucket Name of the bucket to create @return null
abortBucketWorm
php
aliyun/aliyun-oss-php-sdk
samples/BucketWorm.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketWorm.php
MIT
function extendBucketWorm($ossClient, $bucket) { $wormId = "<yourWormId>"; try { $ossClient->ExtendBucketWorm($bucket, $wormId, 120); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Extend the retention days of objects @param $ossClient $ossClient OssClient instance @param $bucket $bucket Name of the bucket to create
extendBucketWorm
php
aliyun/aliyun-oss-php-sdk
samples/BucketWorm.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketWorm.php
MIT
public static function getOssClient() { try { $ossClient = new OssClient(self::accessKeyId, self::accessKeySecret, self::endpoint, false); } catch (OssException $e) { printf(__FUNCTION__ . "creating OssClient instance: FAILED\n"); printf($e->getMessage() . "\n"); return null; } return $ossClient; }
Get an OSSClient instance according to config. @return OssClient An OssClient instance
getOssClient
php
aliyun/aliyun-oss-php-sdk
samples/Common.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/Common.php
MIT
function putBucketLogging($ossClient, $bucket) { $option = array(); // Access logs are stored in the same bucket. $targetBucket = $bucket; $targetPrefix = "access.log"; try { $ossClient->putBucketLogging($bucket, $targetBucket, $targetPrefix, $option); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Set bucket logging configuration @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
putBucketLogging
php
aliyun/aliyun-oss-php-sdk
samples/BucketLogging.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketLogging.php
MIT
function getBucketLogging($ossClient, $bucket) { $loggingConfig = null; $options = array(); try { $loggingConfig = $ossClient->getBucketLogging($bucket, $options); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); print($loggingConfig->serializeToXml() . "\n"); }
Get bucket logging configuration @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
getBucketLogging
php
aliyun/aliyun-oss-php-sdk
samples/BucketLogging.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketLogging.php
MIT
function deleteBucketLogging($ossClient, $bucket) { try { $ossClient->deleteBucketLogging($bucket); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Delete bucket logging configuration @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
deleteBucketLogging
php
aliyun/aliyun-oss-php-sdk
samples/BucketLogging.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketLogging.php
MIT
function putBucketVersioning($ossClient, $bucket) { try { //Set the storage space version control to enable version control (Enabled) or suspend version control (Suspended). $ossClient->putBucketVersioning($bucket, "Enabled"); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Enabled or Suspended bucket version @param OssClient $ossClient OssClient instance @param string $bucket Name of the bucket to create @return null
putBucketVersioning
php
aliyun/aliyun-oss-php-sdk
samples/BucketVersion.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketVersion.php
MIT
function putBucketLifecycle($ossClient, $bucket) { $lifecycleConfig = new LifecycleConfig(); $actions = array(); $actions[] = new LifecycleAction(OssClient::OSS_LIFECYCLE_EXPIRATION, OssClient::OSS_LIFECYCLE_TIMING_DAYS, 3); $lifecycleRule = new LifecycleRule("delete obsoleted files", "obsoleted/", "Enabled", $actions); $lifecycleConfig->addRule($lifecycleRule); $actions = array(); $actions[] = new LifecycleAction(OssClient::OSS_LIFECYCLE_EXPIRATION, OssClient::OSS_LIFECYCLE_TIMING_DATE, '2022-10-12T00:00:00.000Z'); $lifecycleRule = new LifecycleRule("delete temporary files", "temporary/", "Enabled", $actions); $lifecycleConfig->addRule($lifecycleRule); try { $ossClient->putBucketLifecycle($bucket, $lifecycleConfig); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Set bucket lifecycle configuration @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
putBucketLifecycle
php
aliyun/aliyun-oss-php-sdk
samples/BucketLifecycle.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketLifecycle.php
MIT
function getBucketLifecycle($ossClient, $bucket) { $lifecycleConfig = null; try { $lifecycleConfig = $ossClient->getBucketLifecycle($bucket); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); print($lifecycleConfig->serializeToXml() . "\n"); }
Get bucket lifecycle configuration @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
getBucketLifecycle
php
aliyun/aliyun-oss-php-sdk
samples/BucketLifecycle.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketLifecycle.php
MIT
function deleteBucketLifecycle($ossClient, $bucket) { try { $ossClient->deleteBucketLifecycle($bucket); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Delete bucket lifecycle configuration @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
deleteBucketLifecycle
php
aliyun/aliyun-oss-php-sdk
samples/BucketLifecycle.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketLifecycle.php
MIT
function deleteBucketCors($ossClient, $bucket) { try { $ossClient->deleteBucketCors($bucket); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Delete all cors configuraiton of a bucket @param OssClient $ossClient OssClient instance @param string $bucket bucket name @return null
deleteBucketCors
php
aliyun/aliyun-oss-php-sdk
samples/BucketCors.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/BucketCors.php
MIT
function multiuploadFile($ossClient,$bucket){ $object = "b.file"; $file = __FILE__; $options = array( OssClient::OSS_CHECK_MD5 => true, OssClient::OSS_PART_SIZE => 1, OssClient::OSS_HEADERS => array( 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', ), ); try { $result = $ossClient->multiuploadFile($bucket, $object, $file, $options); Common::println("b.file is created".PHP_EOL); Common::println("tag is:".$result['oss-requestheaders']['x-oss-tagging'].PHP_EOL); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Add object tags when uploading parts @param $ossClient OssClient @param $bucket bucket_name
multiuploadFile
php
aliyun/aliyun-oss-php-sdk
samples/ObjectTagging.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/ObjectTagging.php
MIT
function appendObject($ossClient,$bucket){ $object = "g.file"; $content_array = array('Hello OSS', 'Hi OSS'); $options = array( OssClient::OSS_HEADERS => array( 'x-oss-tagging' => 'key1=value1&key2=value2', )); try { $position = $ossClient->appendObject($bucket, $object, $content_array[0], 0, $options); printf($content_array[0].' append object Success'.PHP_EOL); $position = $ossClient->appendObject($bucket, $object, $content_array[1], $position); printf($content_array[1].' append object Success'.PHP_EOL); } catch (OssException $e) { printf(__FUNCTION__ . ": FAILED\n"); printf($e->getMessage() . "\n"); return; } print(__FUNCTION__ . ": OK" . "\n"); }
Add object tags when uploading @param $ossClient OssClient @param $bucket bucket_name string
appendObject
php
aliyun/aliyun-oss-php-sdk
samples/ObjectTagging.php
https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/samples/ObjectTagging.php
MIT
public function __call(string $methodName, array $arguments) { $ruleName = Str::snake($methodName); if (empty($arguments)) { $this->rules[] = $ruleName; return $this; } $rule = $methodName; /** * Lets look for an instance of PathExp. If it exists, we'll wrap the rule in LazyRuleStringify. */ foreach ($arguments as $arg) { if ($arg instanceof PathExp || $arg instanceof self) { $rule = new LazyRuleStringify($ruleName, $arguments); break; } } if (!$rule instanceof LazyRuleStringify) { $rule = sprintf('%s:%s', $ruleName, implode(',', $arguments)); } $this->rules[] = $rule; return $this; }
Allows adding rules w/o defining them in the library e.g. ->min() ->gte(1), ->nullable() @param string $methodName @param array|mixed[] $arguments @return $this
__call
php
square/laravel-hyrule
src/Nodes/AbstractNode.php
https://github.com/square/laravel-hyrule/blob/master/src/Nodes/AbstractNode.php
Apache-2.0
public function __construct() { parent::__construct(''); }
Constructs ObjectNode that sits at root.
__construct
php
square/laravel-hyrule
src/Nodes/RootNode.php
https://github.com/square/laravel-hyrule/blob/master/src/Nodes/RootNode.php
Apache-2.0
protected function getValue($attribute) { assert($this instanceof Validator); if ($attribute === '') { return $this->data; } return parent::getValue($attribute); }
Get the value od a given attribute. Interpret "" as top-level data. @param string $attribute @return mixed
getValue
php
square/laravel-hyrule
src/Validation/ValidatesTopLevelRules.php
https://github.com/square/laravel-hyrule/blob/master/src/Validation/ValidatesTopLevelRules.php
Apache-2.0
protected function isValidatable($rule, $attribute, $value) { assert($this instanceof Validator); if ($attribute === '') { return true; } return parent::isValidatable($rule, $attribute, $value); }
Determine if the attribute is validatable. Allows "" attribute, which will be interpreted as top-level data. @param Rule|string $rule @param string $attribute @param mixed $value @return bool
isValidatable
php
square/laravel-hyrule
src/Validation/ValidatesTopLevelRules.php
https://github.com/square/laravel-hyrule/blob/master/src/Validation/ValidatesTopLevelRules.php
Apache-2.0