PHP Class ALIOSS

Since: 2012-05-31
Author: xiaobing
显示文件 Open project: zblogcn/zblogphp Class Usage Examples

Public Properties

Property Type Description
$OSS_ACL_TYPES OSS ACL数组

Protected Properties

Property Type Description
$use_ssl 是否使用SSL

Public Methods

Method Description
__construct ( $access_id = null, string $access_key = null, string $hostname = null ) 默认构造函数
auth ( array $options ) Authorization
copy_object ( $from_bucket, string $from_object, $to_bucket, string $to_object, string $options = null ) : ResponseCore 拷贝Object
create_bucket ( string $bucket, string $acl = self::OSS_ACL_TYPE_PRIVATE, array $options = null ) : ResponseCore Create Bucket
create_object_dir ( string $bucket, string $object, array $options = null ) : ResponseCore 创建目录(目录和文件的区别在于,目录最后增加'/')
create_object_group ( string $bucket, string $object_group, array $object_arry, array $options = null ) : ResponseCore 创建Object Group
delete_bucket ( string $bucket, array $options = null ) : ResponseCore Delete Bucket
delete_object ( $bucket, string $object, array $options = null ) : ResponseCore 删除object
delete_object_group ( $bucket, string $object_group, array $options = null ) : ResponseCore 删除Object Group
delete_objects ( $bucket, array $objects, array $options = null ) : ResponseCore 批量删除objects
get_bucket_acl ( string $bucket, array $options = null ) : ResponseCore Get Bucket's ACL
get_max_retries ( ) : integer 获取最大尝试次数
get_object ( $bucket, string $object, array $options = null ) : ResponseCore 获得Object内容
get_object_group ( string $bucket, string $object_group, array $options = null ) : ResponseCore 获取Object Group
get_object_group_index ( string $bucket, string $object_group, array $options = null ) : ResponseCore 获取Object Group 的Object List信息
get_object_group_meta ( string $bucket, string $object_group, string $options = null ) : ResponseCore 获得object group的meta信息
get_object_meta ( string $bucket, string $object, string $options = null ) : ResponseCore 获得object的meta信息
get_sign_url ( string $bucket, string $object, integer $timeout = 60, array $options = null ) : string 获取带签名的url
is_gb2312 ( string $str ) : boolean 检测是否GB2312编码
is_object_exist ( $bucket, string $object, array $options = null ) : boolean 检测Object是否存在
list_bucket ( array $options = null ) : ResponseCore Get Buket list
list_object ( string $bucket, array $options = null ) : ResponseCore List Object
set_bucket_acl ( string $bucket, string $acl, array $options = null ) : ResponseCore Set bucket'ACL
set_debug_mode ( boolean $debug_mode = true ) : void 设置debug模式
set_enable_domain_style ( boolean $enable_domain_style = true ) : void 设置路径形式,如果为true,则启用三级域名,如bucket.oss.aliyuncs.com
set_host_name ( string $hostname, integer $port = null ) : void 设置host地址
set_max_retries ( integer $max_retries = 3 ) : void 设置最大尝试次数
set_vhost ( string $vhost ) : void 设置vhost地址
to_query_string ( $options = [] ) : string 生成query params
upload_file_by_content ( string $bucket, string $object, array $options = null ) : ResponseCore 通过在http body中添加内容来上传文件,适合比较小的文件 根据api约定,需要在http header中增加content-length字段
upload_file_by_file ( string $bucket, string $object, string $file, array $options = null ) : ResponseCore 上传文件,适合比较大的文件

Private Methods

Method Description
check_char ( string $str, boolean $gbk = true ) : boolean 检测是否GBK编码
chk_chinese ( $str ) : boolean 检测是否含有中文
hex_to_base64 ( string $str ) : string 转化十六进制的数据为base64
is_empty ( string $name, string $errMsg ) : void 校验BUCKET/OBJECT/OBJECT GROUP是否为空
log ( string $msg ) : void 记录日志
make_object_group_xml ( string $bucket, array $object_array ) : string 转化object数组为固定个xml格式
read_dir ( string $dir, $exclude = ".|..|.svn", boolean $recursive = false ) : array 读取目录
s_replace ( $subject )
set_options_header ( string $key, string $value, array &$options ) : void 设置http header
validate_bucket ( string $bucket ) : boolean 检验bucket名称是否合法 bucket的命名规范: 1. 只能包括小写字母,数字 2. 必须以小写字母或者数字开头 3. 长度必须在3-63字节之间
validate_content ( array $options ) : string 检测上传文件的内容
validate_content_length ( array $options ) : void 验证文件长度
validate_object ( string $object ) : boolean 检验object名称是否合法 object命名规范: 1. 规则长度必须在1-1023字节之间 2. 使用UTF-8编码
validate_options ( array $options ) : boolean 检验$options

Method Details

__construct() public method

默认构造函数
Since: 2011-11-08
public __construct ( $access_id = null, string $access_key = null, string $hostname = null )
$access_key string (Optional)
$hostname string (Optional)

auth() public method

Authorization
Since: 2012-05-31
public auth ( array $options )
$options array (Required)

copy_object() public method

拷贝Object
Since: 2011-12-21
public copy_object ( $from_bucket, string $from_object, $to_bucket, string $to_object, string $options = null ) : ResponseCore
$from_object string (Required)
$to_object string (Required)
$options string (Optional)
return ResponseCore

create_bucket() public method

Create Bucket
Since: 2011-11-14
public create_bucket ( string $bucket, string $acl = self::OSS_ACL_TYPE_PRIVATE, array $options = null ) : ResponseCore
$bucket string (Required)
$acl string (Optional)
$options array (Optional)
return ResponseCore

create_object_dir() public method

创建目录(目录和文件的区别在于,目录最后增加'/')
Since: 2011-11-14
public create_object_dir ( string $bucket, string $object, array $options = null ) : ResponseCore
$bucket string
$object string
$options array
return ResponseCore

create_object_group() public method

创建Object Group
Since: 2011-11-14
public create_object_group ( string $bucket, string $object_group, array $object_arry, array $options = null ) : ResponseCore
$bucket string (Required) Bucket名称
$object_group string (Required) Object Group名称
$object_arry array (Required) object数组,所有的object必须在同一个bucket下 其中$object 数组的格式如下: $object = array( $object1, $object2, ... )
$options array (Optional)
return ResponseCore

delete_bucket() public method

Delete Bucket
Since: 2011-11-14
public delete_bucket ( string $bucket, array $options = null ) : ResponseCore
$bucket string (Required)
$options array (Optional)
return ResponseCore

delete_object() public method

删除object
Since: 2011-11-14
public delete_object ( $bucket, string $object, array $options = null ) : ResponseCore
$object string (Required)
$options array (Optional)
return ResponseCore

delete_object_group() public method

删除Object Group
Since: 2011-11-14
public delete_object_group ( $bucket, string $object_group, array $options = null ) : ResponseCore
$object_group string (Required)
$options array (Optional)
return ResponseCore

delete_objects() public method

批量删除objects
Since: 2012-03-09
public delete_objects ( $bucket, array $objects, array $options = null ) : ResponseCore
$objects array (Required)
$options array (Optional)
return ResponseCore

get_bucket_acl() public method

Get Bucket's ACL
Since: 2011-11-14
public get_bucket_acl ( string $bucket, array $options = null ) : ResponseCore
$bucket string (Required)
$options array (Optional)
return ResponseCore

get_max_retries() public method

获取最大尝试次数
Since: 2012-05-29
public get_max_retries ( ) : integer
return integer

get_object() public method

获得Object内容
Since: 2011-11-14
public get_object ( $bucket, string $object, array $options = null ) : ResponseCore
$object string (Required)
$options array (Optional)
return ResponseCore

get_object_group() public method

获取Object Group
Since: 2011-11-14
public get_object_group ( string $bucket, string $object_group, array $options = null ) : ResponseCore
$bucket string (Required)
$object_group string (Required)
$options array (Optional)
return ResponseCore

get_object_group_index() public method

获取Object Group 的Object List信息
Since: 2011-11-14
public get_object_group_index ( string $bucket, string $object_group, array $options = null ) : ResponseCore
$bucket string (Required)
$object_group string (Required)
$options array (Optional)
return ResponseCore

get_object_group_meta() public method

获得object group的meta信息
Since: 2011-11-14
public get_object_group_meta ( string $bucket, string $object_group, string $options = null ) : ResponseCore
$bucket string (Required)
$object_group string (Required)
$options string (Optional)
return ResponseCore

get_object_meta() public method

获得object的meta信息
Since: 2011-11-14
public get_object_meta ( string $bucket, string $object, string $options = null ) : ResponseCore
$bucket string (Required)
$object string (Required)
$options string (Optional)
return ResponseCore

get_sign_url() public method

获取带签名的url
Since: 2011-12-21
public get_sign_url ( string $bucket, string $object, integer $timeout = 60, array $options = null ) : string
$bucket string (Required)
$object string (Required)
$timeout integer (Optional)
$options array (Optional)
return string

is_gb2312() public method

检测是否GB2312编码
Since: 2012-03-20
public is_gb2312 ( string $str ) : boolean
$str string
return boolean false UTF-8编码 TRUE GB2312编码

is_object_exist() public method

检测Object是否存在
Since: 2011-11-14
public is_object_exist ( $bucket, string $object, array $options = null ) : boolean
$object string (Required)
$options array (Optional)
return boolean

list_bucket() public method

Get Buket list
Since: 2011-11-14
public list_bucket ( array $options = null ) : ResponseCore
$options array (Optional)
return ResponseCore

list_object() public method

List Object
Since: 2011-11-14
public list_object ( string $bucket, array $options = null ) : ResponseCore
$bucket string (Required)
$options array (Optional) 其中options中的参数如下 $options = array( 'max-keys' => max-keys用于限定此次返回object的最大数,如果不设定,默认为100,max-keys取值不能大于100。 'prefix' => 限定返回的object key必须以prefix作为前缀。注意使用prefix查询时,返回的key中仍会包含prefix。 'delimiter' => 是一个用于对Object名字进行分组的字符。所有名字包含指定的前缀且第一次出现delimiter字符之间的object作为一组元素 'marker' => 用户设定结果从marker之后按字母排序的第一个开始返回。 ) 其中 prefix,marker用来实现分页显示效果,参数的长度必须小于256字节。
return ResponseCore

set_bucket_acl() public method

Set bucket'ACL
Since: 2011-11-14
public set_bucket_acl ( string $bucket, string $acl, array $options = null ) : ResponseCore
$bucket string (Required)
$acl string (Required)
$options array (Optional)
return ResponseCore

set_debug_mode() public method

设置debug模式
Since: 2012-05-29
public set_debug_mode ( boolean $debug_mode = true ) : void
$debug_mode boolean (Optional)
return void

set_enable_domain_style() public method

设置路径形式,如果为true,则启用三级域名,如bucket.oss.aliyuncs.com
Since: 2012-06-11
public set_enable_domain_style ( boolean $enable_domain_style = true ) : void
$enable_domain_style boolean
return void

set_host_name() public method

设置host地址
Since: 2012-06-11
public set_host_name ( string $hostname, integer $port = null ) : void
$hostname string host name
$port integer int
return void

set_max_retries() public method

设置最大尝试次数
Since: 2012-05-29
public set_max_retries ( integer $max_retries = 3 ) : void
$max_retries integer
return void

set_vhost() public method

设置vhost地址
Since: 2012-06-11
public set_vhost ( string $vhost ) : void
$vhost string vhost
return void

to_query_string() public method

生成query params
Since: 2012-03-04
public to_query_string ( $options = [] ) : string
return string 返回诸如 key1=value1&key2=value2

upload_file_by_content() public method

通过在http body中添加内容来上传文件,适合比较小的文件 根据api约定,需要在http header中增加content-length字段
Since: 2011-11-14
public upload_file_by_content ( string $bucket, string $object, array $options = null ) : ResponseCore
$bucket string (Required)
$object string (Required)
$options array (Optional)
return ResponseCore

upload_file_by_file() public method

上传文件,适合比较大的文件
Since: 2012-02-28
public upload_file_by_file ( string $bucket, string $object, string $file, array $options = null ) : ResponseCore
$bucket string (Required)
$object string (Required)
$file string (Required)
$options array (Optional)
return ResponseCore

Property Details

$OSS_ACL_TYPES public_oe static_oe property

OSS ACL数组
public static $OSS_ACL_TYPES

$use_ssl protected_oe property

是否使用SSL
protected $use_ssl