Constants

OSS_CONTENT

OSS_CONTENT = 'content'

OSS_LENGTH

OSS_LENGTH = 'length'

OSS_HEADERS

OSS_HEADERS = 'headers'

OSS_MAX_OBJECT_GROUP_VALUE

OSS_MAX_OBJECT_GROUP_VALUE = 1000

OSS_MAX_PART_SIZE

OSS_MAX_PART_SIZE = 5368709120

OSS_MID_PART_SIZE

OSS_MID_PART_SIZE = 10485760

OSS_MIN_PART_SIZE

OSS_MIN_PART_SIZE = 102400

Methods

toQueryString()

toQueryString(mixed  $options = array()) : mixed

Generate query params

Parameters

mixed $options

Returns

mixed —

sReplace()

sReplace(string  $subject) : string

Html encoding '<', '>', '&', '\', '"' in subject parameter.

Parameters

string $subject

Returns

string —

chkChinese()

chkChinese( $str) : int

Check whether the string includes any chinese character

Parameters

$str

Returns

int —

isGb2312()

isGb2312(string  $str) : bool

Checks if the string is encoded by GB2312.

Parameters

string $str

Returns

bool —

false UTF-8 encoding TRUE GB2312 encoding

checkChar()

checkChar(string  $str, bool  $gbk = true) : bool

Checks if the string is encoded by GBK

Parameters

string $str
bool $gbk

Returns

bool —

validateBucket()

validateBucket(string  $bucket) : bool

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.

Parameters

string $bucket

Bucket name

Returns

bool —

validateObject()

validateObject(string  $object) : bool

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 '\\'.

  1. Must be encoded in UTF-8.

Parameters

string $object

Object名称

Returns

bool —

startsWith()

startsWith(string  $str, string  $findMe) : bool

Checks if $str starts with $findMe

Parameters

string $str
string $findMe

Returns

bool —

createBucketXmlBody()

createBucketXmlBody(string  $storageClass) : string

Generate the xml message of createBucketXmlBody.

Parameters

string $storageClass

Returns

string —

validateOptions()

validateOptions(array  $options) : bool

validate $options

Parameters

array $options

Throws

\OSS\Core\OssException

Returns

bool —

validateContent()

validateContent( $content) : mixed

check whether the Content is valid.

Parameters

$content

string

Throws

\OSS\Core\OssException

Returns

mixed —

throwOssExceptionWithMessageIfEmpty()

throwOssExceptionWithMessageIfEmpty(string  $name, string  $errMsg) : void

Check if BUCKET/OBJECT/OBJECT GROUP is empty.

Parameters

string $name
string $errMsg

Throws

\OSS\Core\OssException

generateFile()

generateFile( $filename,  $size) : mixed

This is a method for test only. DO NOT USE.

Parameters

$filename
$size

Returns

mixed —

getMd5SumForFile()

getMd5SumForFile( $filename,  $from_pos,  $to_pos) : string

Get MD5 of the file.

Parameters

$filename
$from_pos
$to_pos

Returns

string —

isWin()

isWin() : bool

Check if the OS is Windows. The default encoding in Windows is GBK.

Returns

bool —

encodePath()

encodePath( $file_path) : string

Encodes the file path from GBK to UTF-8.

The default encoding in Windows is GBK. And if the file path is in Chinese, the file would not be found without the transcoding to UTF-8.

Parameters

$file_path

Returns

string —

isIPFormat()

isIPFormat(string  $endpoint) : bool

Check if the endpoint is in the IPv4 format, such as xxx.xxx.xxx.xxx:port or xxx.xxx.xxx.xxx.

Parameters

string $endpoint

The endpoint to check.

Returns

bool —

getHostPortFromEndpoint()

getHostPortFromEndpoint(string  $endpoint) : bool

Get the host:port from endpoint.

Parameters

string $endpoint

the endpoint.

Returns

bool —

createDeleteObjectsXmlBody()

createDeleteObjectsXmlBody(string[]  $objects, bool  $quiet) : string

Generate the xml message of DeleteMultiObjects.

Parameters

string[] $objects
bool $quiet

Returns

string —

createDeleteObjectVersionsXmlBody()

createDeleteObjectVersionsXmlBody(\OSS\Core\DeleteObjectInfo[]  $objects, bool  $quiet) : string

Generate the xml message of DeleteMultiObjects.

Parameters

\OSS\Core\DeleteObjectInfo[] $objects
bool $quiet

Returns

string —

createCompleteMultipartUploadXmlBody()

createCompleteMultipartUploadXmlBody(array[]  $listParts) : string

Generate the xml message of CompleteMultipartUpload.

Parameters

array[] $listParts

Returns

string —

readDir()

readDir(string  $dir, string  $exclude = ".|..|.svn|.git", bool  $recursive = false) : string[]

Read the directory, return a associative array in which the MD5 is the named key and the <path,filanme> is the value.

Parameters

string $dir
string $exclude
bool $recursive

Returns

string[] —

decodeKey()

decodeKey(string  $key, string  $encoding) : string

Decode key based on the encoding type

Parameters

string $key
string $encoding

Returns

string —