Skip to content

duanliguo/bos-php-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bos-php-sdk

非官方版本

RESTful api 文档:http://bce.baidu.com/doc/BOS/API.html

php < 5.3

如果是在开发机上面,并且通过jumbo install odp-php odp-php-pear-PHPUnit安装的php,那么默认的版本可能是php 5.2.17,此时应该使用git checkout php-5.2这个分支的代码。

php >= 5.3

默认的master分支代码应该工作在php >= 5.3.0的环境下面,如果你的环境符合这个需求,可以直接使用master分支的代码。

测试用例

检出代码之后,执行make即可,必须保证在内网的环境下才可以正常的运行测试用例。

如何使用

php >= 5.3

define('__BOS_CLIENT_ROOT', 'the bos-php-sdk dir');
require_once __BOS_CLIENT_ROOT . "/baidubce/services/bos/BosClient.php";

use baidubce\services\bos\BosClient;

$config = array(
    'AccessKeyId' => 'your ak',
    'AccessKeySecret' => 'your sk',
    'TimeOut' => 5000, // 5s
    'Host' => 'bos.bj.baidubce.com'
);
$client = new BosClient($config);
$client->createBucket('my-bucket');
$client->putObjectFromString('my-bucket', 'this/is/my/file.txt', 'hello world, this is file content');

$url = $client->generatePresignedUrl('my-bucket', 'this/is/my/file.txt');
print_r(file_get_contents($url));

php < 5.3

define('__BOS_CLIENT_ROOT', 'the bos-php-sdk dir');
require_once __BOS_CLIENT_ROOT . "/baidubce/services/bos/BosClient.php";

$config = array(
    'AccessKeyId' => 'your ak',
    'AccessKeySecret' => 'your sk',
    'TimeOut' => 5000, // 5s
    'Host' => 'bos.bj.baidubce.com'
);
$client = new baidubce_services_bos_BosClient($config);
$client->createBucket('my-bucket');
$client->putObjectFromString('my-bucket', 'this/is/my/file.txt', 'hello world, this is file content');

$url = $client->generatePresignedUrl('my-bucket', 'this/is/my/file.txt');
print_r(file_get_contents($url));

Releases

No releases published

Packages

No packages published

Languages

  • PHP 94.9%
  • Python 4.7%
  • Makefile 0.4%