Class SaeS3

Description

SaeS3 class

使用S3存储服务需要手工加载saes3.ex.class.php

  1.  require_once('saes3.ex.class.php');
  2.  
  3.  $s new SaeS3();
  4.  $url $s->write'domain' 'test/test.txt' 'the content!' );
  5.  // will return 'http://domain.appname.s3.sinaapp.com/test/test.txt'
  6.  
  7.  echo $s->getUrl'example' 'thebook' );
  8.  // will echo 'http://exampale.s3.sae.sina.com.cn/thebook';
  9.  
  10.  echo file_get_contents("http://domain.appname.s3.sinaapp.com/test/test.txt");
  11.  // will echo 'the content!';

常见错误码参考:

  • errno: 0 成功
  • errno: -2 配额统计错误
  • errno: -3 权限不足
  • errno: -12 存储服务器返回错误
  • errno: -18 文件不存在
  • errno: -101 参数错误
  • errno: -102 存储服务器连接失败

  • author: Elmer Zhang

Located in /saes3.ex.class.php (line 45)

SaeObject
   |
   --SaeS3
Method Summary
void __construct ([string $_accessKey = ''], [string $_secretKey = ''])
bool delete (string $domain, string $filename)
string errmsg ()
int errno ()
array getAttr (string $domain, string $filename, [array $attrKey = array()])
int getDomainCapacity ([string $domain = ''])
array getList (string $domain, [string $dir = ''], [string $limit = 1000])
string getUrl (string $domain, string $filename)
void setAuth (string $akey, string $skey)
void write (string $domain, string $destFile, [string $content = ""], [string $size = -1])
Methods
Constructor __construct (line 112)

构造函数

$_accessKey与$_secretKey可以为空,为空的情况下可以认为是公开读文件

  • author: Elmer Zhang
  • access: public
void __construct ([string $_accessKey = ''], [string $_secretKey = ''])
  • string $_accessKey
  • string $_secretKey
delete (line 316)

删除文件

  • author: Elmer Zhang
  • access: public
bool delete (string $domain, string $filename)
  • string $domain
  • string $filename
errmsg (line 142)

返回运行过程中的错误信息

  • author: Elmer Zhang
  • access: public
string errmsg ()
errno (line 156)

返回运行过程中的错误代码

  • author: Elmer Zhang
  • access: public
int errno ()
getAttr (line 280)

获取文件属性

  • author: Elmer Zhang
  • access: public
array getAttr (string $domain, string $filename, [array $attrKey = array()])
  • string $domain
  • string $filename
  • array $attrKey: 属性值,如 array("fileName", "length"),当attrKey为空时,以关联数组方式返回该文件的所有属性
getDomainCapacity (line 462)

获取domain所占存储的大小

  • author: Elmer Zhang
  • access: public
int getDomainCapacity ([string $domain = ''])
  • string $domain
getList (line 239)

获取指定domain下的文件名列表

  • author: Elmer Zhang
  • access: public
array getList (string $domain, [string $dir = ''], [string $limit = 1000])
  • string $domain: 存储域,在在线管理平台.S3页面可进行管理
  • string $dir: 目录,如 test, test/test2
  • string $limit: 返回条数,默认1000条
getUrl (line 171)

取得访问存储文件的url

  • author: Elmer Zhang
  • access: public
string getUrl (string $domain, string $filename)
  • string $domain
  • string $filename
setAuth (line 130)

设置key

当需要访问其他APP的数据时使用

  • author: Elmer Zhang
  • access: public
void setAuth (string $akey, string $skey)
  • string $akey
  • string $skey
write (line 202)

将数据写入存储

  • author: Elmer Zhang
  • access: public
void write (string $domain, string $destFile, [string $content = ""], [string $size = -1])
  • string $domain: 存储域,在在线管理平台.Sae S3页面可进行管理
  • string $destFile: 文件名
  • string $content: 文件内容,支持二进制数据
  • string $size: 写入长度,默认为不限制

Documentation generated on Wed, 11 Aug 2010 17:35:01 +0800 by phpDocumentor 1.4.3