Commit 64f74747 authored by shajiaiming's avatar shajiaiming

Merge branch 'master' into feature/issue_coin

parents 8e3319ee dd1cd4d3
......@@ -129,7 +129,7 @@ class ApplicationController extends BaseController
$icon_Infos = CoinImage::getItemsByIds($icon_Items);
foreach($data as $key => &$value){
if($value['icon']){
$value['icon'] = $icon_Infos[$value['icon']]['base_url'].$icon_Infos[$value['icon']]['file_url'];
$value['icon'] = Yii::$app->params['service']['OssService']['url'].$icon_Infos[$value['icon']]['file_url'];
}else{
$value['icon'] = "";
}
......@@ -157,7 +157,7 @@ class ApplicationController extends BaseController
$name = json_decode($value['name'], true);
$value['name'] = $name[$this->lang];
if($value['icon']){
$value['icon'] = $icon_Infos[$value['icon']]['base_url'].$icon_Infos[$value['icon']]['file_url'];
$value['icon'] = Yii::$app->params['service']['OssService']['url'].$icon_Infos[$value['icon']]['file_url'];
}else{
$value['icon'] = '';
}
......
......@@ -21,6 +21,8 @@ class TickerController extends BaseController
$page = Yii::$app->request->get('page', 1);
$device_code = Yii::$app->request->get('device_code', '');
$exchange = Yii::$app->request->get('exchange', 'zhaobi');
$data_value = Yii::$app->request->get('data-value','');
$sort = Yii::$app->request->get('sort','');
$exchange_arr = ['huobi', 'binance', 'okex', 'zhaobi'];
if (!in_array($exchange, $exchange_arr)) {
......
......@@ -27,22 +27,22 @@ class ApplicateRecommendController extends BaseController
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
$type = $request->get('type','');
if($id && $type){
$recommend = CoinApplicateRecommend::getRecommend($id,$type);
if($recommend){
return ['code' => 1,'msg' =>'分类/应用已经添加为首页推荐,不能再添加'];
$id = $request->get('id', '');
$type = $request->get('type', '');
if ($id && $type) {
$recommend = CoinApplicateRecommend::getRecommend($id, $type);
if ($recommend) {
return ['code' => 1, 'msg' => '分类/应用已经添加为首页推荐,不能再添加'];
}
$count = CoinApplicateRecommend::getRecommendCount();
if($count >= 8){
return ['code' => 1,'msg' =>'首页推荐分类/应用数量已经8个,无法再添加'];
if ($count >= 8) {
return ['code' => 1, 'msg' => '首页推荐分类/应用数量已经8个,无法再添加'];
}
if($type == 1){ //分类
if ($type == 1) { //分类
$applicate_category = CoinApplicationCategory::getCategoryById($id);
$name = $applicate_category->name;
$user_platform_id = $applicate_category->platform_id;
}else{ //应用
} else { //应用
$applicate = CoinApplication::getApplicate($id);
$name = $applicate->name;
$user_platform_id = $applicate->platform_id;
......@@ -53,9 +53,9 @@ class ApplicateRecommendController extends BaseController
$recommend->name = $name;
$recommend->platform_id = $user_platform_id;
$recommend->save();
return ['code' => 0,'msg' => '首页推荐添加成功'];
}else{
return ['code' => 1 ,'msg' => '首页推荐添加失败'];
return ['code' => 0, 'msg' => '首页推荐添加成功'];
} else {
return ['code' => 1, 'msg' => '首页推荐添加失败'];
}
}
}
......@@ -69,17 +69,17 @@ class ApplicateRecommendController extends BaseController
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
$type = $request->get('type','');
if($id && $type){
$recommend = CoinApplicateRecommend::getRecommend($id,$type);
if(!$recommend){
return ['code' => 1,'msg' =>'首页推荐不存在,不能删除'];
$id = $request->get('id', '');
$type = $request->get('type', '');
if ($id && $type) {
$recommend = CoinApplicateRecommend::getRecommend($id, $type);
if (!$recommend) {
return ['code' => 1, 'msg' => '首页推荐不存在,不能删除'];
}
$recommend->delete();
return ['code' => 0,'msg' => '首页推荐删除成功'];
}else{
return ['code' => 1 ,'msg' => '首页推荐删除失败'];
return ['code' => 0, 'msg' => '首页推荐删除成功'];
} else {
return ['code' => 1, 'msg' => '首页推荐删除失败'];
}
}
}
......@@ -91,25 +91,25 @@ class ApplicateRecommendController extends BaseController
{
$user_platform_id = Yii::$app->user->identity->platform_id;
if(Yii::$app->request->isAjax){
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$condition = [];
if(1 !== $user_platform_id){
if (1 !== $user_platform_id) {
$condition = ['platform_id' => $user_platform_id];
}
$data = CoinApplicateRecommend::find()->joinWith('platform')->where($condition)->orderBy('sort asc')->asArray()->all();
$icon_Items = array_column($data,'icon');
$icon_Items = array_column($data, 'icon');
$icon_Infos = CoinImage::getItemsByIds($icon_Items);
foreach ($data as &$value){
foreach ($data as &$value) {
$value['coin_name'] = isset($value['platform']['name']) ? $value['platform']['name'] : '';
if($value['icon']){
$value['icon_url'] = $icon_Infos[$value['icon']]['base_url'].$icon_Infos[$value['icon']]['file_url'];
}else{
if ($value['icon']) {
$value['icon_url'] = Yii::$app->params['service']['OssService']['url'] . $icon_Infos[$value['icon']]['file_url'];
} else {
$value['icon_url'] = '';
}
}
return [ 'data' =>$data, 'code' => 0];
return ['data' => $data, 'code' => 0];
}
return $this->render('index');
}
......@@ -123,19 +123,19 @@ class ApplicateRecommendController extends BaseController
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = 'json';
$request = Yii::$app->request;
$id = $request->get('id', '');
$type = $request->get('type','');
$sort = $request->get('sort',1);
if($id && $type){
$recommend = CoinApplicateRecommend::getRecommend($id,$type);
if(!$recommend){
return ['code' => 1,'msg' =>'首页推荐不存在,不能设置排序'];
$id = $request->get('id', '');
$type = $request->get('type', '');
$sort = $request->get('sort', 1);
if ($id && $type) {
$recommend = CoinApplicateRecommend::getRecommend($id, $type);
if (!$recommend) {
return ['code' => 1, 'msg' => '首页推荐不存在,不能设置排序'];
}
$recommend->sort=$sort;
$recommend->sort = $sort;
$recommend->save();
return ['code' => 0,'msg' => '首页推荐排序设置成功'];
}else{
return ['code' => 1 ,'msg' => '首页推荐排序设置失败'];
return ['code' => 0, 'msg' => '首页推荐排序设置成功'];
} else {
return ['code' => 1, 'msg' => '首页推荐排序设置失败'];
}
}
}
......@@ -146,21 +146,21 @@ class ApplicateRecommendController extends BaseController
*/
public function actionSetIcon()
{
if(Yii::$app->request->isPost){
if (Yii::$app->request->isPost) {
Yii::$app->response->format = 'json';
$id = Yii::$app->request->post('id',0);
$icon = Yii::$app->request->post('icon',0);
if($id && $icon){
$id = Yii::$app->request->post('id', 0);
$icon = Yii::$app->request->post('icon', 0);
if ($id && $icon) {
$recommend = CoinApplicateRecommend::getRecommendById($id);
if($recommend){
if ($recommend) {
$recommend->icon = $icon;
$recommend->save();
return ['code' => 0, 'msg' => '图片添加成功'];
}else{
} else {
return ['code' => 1, 'msg' => '首页推荐不存在'];
}
}else{
return ['code' => 1,'msg'=> '图片添加失败'];
} else {
return ['code' => 1, 'msg' => '图片添加失败'];
}
}
}
......
......@@ -144,8 +144,8 @@ class ApplicationCategoryController extends BaseController
$coin = CoinApplicationCategory::getAppCategory($id);
$icon_model = CoinImage::findOne($coin['icon']);
$banner_model = CoinImage::findOne($coin['banner']);
$coin['icon_url'] = empty($icon_model) ? '' : $icon_model->base_url . $icon_model->file_url;
$coin['banner_image_url'] = empty($banner_model) ? '' : $banner_model->base_url . $banner_model->file_url;
$coin['icon_url'] = empty($icon_model) ? '' : Yii::$app->params['service']['OssService']['url'] . $icon_model->file_url;
$coin['banner_image_url'] = empty($banner_model) ? '' : Yii::$app->params['service']['OssService']['url'] . $banner_model->file_url;
$name_arr = json_decode($coin['name'], true);
$coin['name_ja'] = isset($name_arr['ja']) ? $name_arr['ja'] : '';
$coin['name_zh'] = isset($name_arr['zh-CN']) ? $name_arr['zh-CN'] : '';
......
......@@ -146,22 +146,23 @@ class ApplicationController extends BaseController
$app_cate = CoinAppCate::getAppCate($category_id, $id);
if ($applicate['icon'] && isset($coin_items[$applicate['icon']])) {
$icon_info = $coin_items[$applicate['icon']];
$applicate['icon_url'] = $icon_info['base_url'] . $icon_info['file_url'];
$applicate['icon_url'] = Yii::$app->params['service']['OssService']['url'] . $icon_info['file_url'];
} else {
$applicate['icon_url'] = "";
}
if ($applicate['h5_icon']) {
$icon_info = $coin_items[$applicate['h5_icon']];
$applicate['h5_icon_url'] = $icon_info['base_url'] . $icon_info['file_url'];
$applicate['h5_icon_url'] = Yii::$app->params['service']['OssService']['url'] . $icon_info['file_url'];
} else {
$applicate['h5_icon_url'] = "";
}
if ($applicate['introduce_image']) {
$icon_info = $coin_items[$applicate['introduce_image']];
$applicate['introduce_image_url'] = $icon_info['base_url'] . $icon_info['file_url'];
$applicate['introduce_image_url'] = Yii::$app->params['service']['OssService']['url'] . $icon_info['file_url'];
} else {
$applicate['introduce_image_url'] = "";
}
#echo json_encode($applicate);exit;
$applicate['sort'] = $app_cate->sort;
$name_arr = json_decode($applicate['name'], true);
$applicate['name_ja'] = $name_arr['ja'];
......
<?php
namespace backend\controllers;
use common\models\psources\CoinImage;
use Yii;
use OSS\OssClient;
use yii\web\UploadedFile;
use yii\validators\ImageValidator;
class OssController extends BaseController
{
protected $accessKeyId = "LTAI4FxZ787zpBmjLmr6yMwA";
protected $accessKeySecret = "5OMu030RFIE2KP3fNJrhVRTlVqBLaE";
protected $endpoint = "http://oss-cn-shanghai.aliyuncs.com";
protected $bucket = "bqbwallet";
public function actionUpload()
{
Yii::$app->response->format = 'json';
$type = Yii::$app->request->post('image_type', '');
$uploaded_file = UploadedFile::getInstanceByName('file');
$object = md5(date('Y-m-d H:i:s') . $uploaded_file->tempName) . '.' . $uploaded_file->extension;
$filePath = $uploaded_file->tempName;
$ossClient = new OssClient($this->accessKeyId, $this->accessKeySecret, $this->endpoint);
$result = $ossClient->uploadFile($this->bucket, (empty($type) ? '' : $type . '/') . $object, $filePath);
if (!isset($result["info"]['url'])) {
return ['code' => 1, 'msg' => '上传失败'];
}
if (in_array($type, ['coin', 'banner', 'h5_banner', 'h5_icon', 'application', 'h5_application'])) {
$file_url = explode('http://bqbwallet.oss-cn-shanghai.aliyuncs.com', $result["info"]['url']);
$image_id = CoinImage::addOneRecord($file_url[1]);
}
return ['code' => 0, 'msg' => '上传成功', 'data' => ['src' => $result["info"]['url'], 'image_id' => !empty($image_id) ? $image_id : 0]];
}
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
</div>
<div class="layui-row add" style="display: none;padding: 5px;" id="_form">
<div class="layui-col-xs6 layui-col-sm6 layui-col-md11">
<form class="layui-form" action="javascript:void(0)" id="form1" method="post" lay-filter="form1">
<form class="layui-form" action="javascript:void(0)" id="form1" method="post" lay-filter="form1">
<input type="hidden" name="_csrf" value="<?= Yii::$app->request->getCsrfToken() ?>">
<input type="hidden" name="id" value="">
<div class="layui-form-item">
......@@ -92,34 +92,34 @@
var form = layui.form;
form.render();
table.on('tool(table1)', function(obj) {
table.on('tool(table1)', function (obj) {
var event = obj.event;
var data = obj.data;
if (event === 'del') {
var index = layer.confirm("确认删除?", {icon: 3, title: '删除'}, function () {
$.get('/admin/applicate-recommend/delete', {id: data.relate_id,type:data.type}, function (rev) {
$.get('/admin/applicate-recommend/delete', {id: data.relate_id, type: data.type}, function (rev) {
layer.msg(rev.msg);
if (0==rev.code) {
if (0 == rev.code) {
table.reload('table1');
}
});
});
}else if(event === 'edit'){
} else if (event === 'edit') {
var index = layer.open({
title: '编辑图片',
area: '800px',
type: 1,
content: $("#_form"),
btn: ['保存', '取消'],
success: function() {
success: function () {
form.val("form1", {
id: data.id,
icon: data.icon,
});
$("#icon1").attr('src', data.icon_url);
},
btn1: function() {
$.post('/admin/applicate-recommend/set-icon', $("#form1").serialize(), function(rev) {
btn1: function () {
$.post('/admin/applicate-recommend/set-icon', $("#form1").serialize(), function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
layer.close(index);
......@@ -128,11 +128,11 @@
}
});
},
btn2: function() {
btn2: function () {
layer.close(index);
$("#_form").css('display', 'none');
},
cancel: function() {
cancel: function () {
layer.close(index);
$("#_form").css('display', 'none');
}
......@@ -140,14 +140,18 @@
}
});
//监听单元格编辑
table.on('edit(table1)', function(obj){
table.on('edit(table1)', function (obj) {
var value = obj.value; //得到修改后的值
var data = obj.data; //得到所在行所有键值
$.get('/admin/applicate-recommend/set-sort', {id:data.relate_id,type:data.type,sort:value}, function(rev) {
$.get('/admin/applicate-recommend/set-sort', {
id: data.relate_id,
type: data.type,
sort: value
}, function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
table.reload('table1',{});
}else{
table.reload('table1', {});
} else {
}
});
......@@ -157,12 +161,12 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data: {_csrf: $_csrf},
url: '/admin/oss/upload',
data: {_csrf: $_csrf, image_type: 'coin'},
done: function (res) {
if(res.code == 0){
if (res.code == 0) {
$("input[name='icon']").val(res.data.image_id);
$("#icon1").attr('src', res.data.image_src);
$("#icon1").attr('src', res.data.src);
}
},
error: function (res) {
......
......@@ -40,7 +40,7 @@
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">排序</label>
<div class="layui-input-block" style="width: 250px">
<div class="layui-input-block" style="width: 250px">
<input type="text" name="sort" required lay-verify="required" placeholder=""
autocomplete="off" value=""
class="layui-input">
......@@ -50,8 +50,7 @@
<div class="layui-inline">
<label class="layui-form-label">图标</label>
<div class="layui-input-block">
<img src="" style="margin-top: 11px; max-width: 32px; max-height: 32px"
id="icon1">
<img src="" style="margin-top: 11px; max-width: 32px; max-height: 32px" id="icon1">
</div>
<input type="hidden" name="icon" value="">
</div>
......@@ -98,12 +97,12 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data: {_csrf: $_csrf},
url: '/admin/oss/upload',
data: {_csrf: $_csrf, image_type: 'coin'},
done: function (res) {
if(res.code == 0){
if (res.code == 0) {
$("input[name='icon']").val(res.data.image_id);
$("#icon1").attr('src', res.data.image_src);
$("#icon1").attr('src', res.data.src);
}
},
error: function (res) {
......@@ -113,12 +112,12 @@
uploader.render({
elem: "#upload2",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:2},
url: '/admin/oss/upload',
data: {_csrf: $_csrf, image_type: 'banner'},
done: function (res) {
if(res.code == 0){
if (res.code == 0) {
$("input[name='banner']").val(res.data.image_id);
$("#icon2").attr('src', res.data.image_src);
$("#icon2").attr('src', res.data.src);
}
},
error: function (res) {
......
......@@ -19,7 +19,7 @@
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<button class="layui-btn layui-btn-default add_banner" >添加H5 banner</button>
<button class="layui-btn layui-btn-default add_banner">添加H5 banner</button>
<table class="layui-table" id="table1" lay-filter="table1"></table>
</div>
</div>
......@@ -28,9 +28,10 @@
<div class="layui-row add" style="display: none;padding: 5px;" id="_form">
<div class="layui-col-xs6 layui-col-sm6 layui-col-md11">
<form class="layui-form" action="javascript:void(0)" id="form1" method="post" lay-filter="form1">
<form class="layui-form" action="javascript:void(0)" id="form1" method="post" lay-filter="form1">
<input type="hidden" name="_csrf" value="<?= Yii::$app->request->getCsrfToken() ?>">
<input id="applicate_category_id" name="applicate_category_id" type="hidden" value="<?= $applicate_category->id ?>">
<input id="applicate_category_id" name="applicate_category_id" type="hidden"
value="<?= $applicate_category->id ?>">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">图标</label>
......@@ -68,7 +69,7 @@
var applicate_category_id = $("#applicate_category_id").val();
table.render({
elem: '#table1',
url: '/admin/application-category/banner-index?id='+applicate_category_id,
url: '/admin/application-category/banner-index?id=' + applicate_category_id,
cols: [[
{
field: 'id',
......@@ -78,15 +79,15 @@
{
field: 'image_url',
title: '图片链接',
templet: function(d){
return "<a href='"+d.image_url+"' target='_blank'>"+d.image_url+"</a>";
templet: function (d) {
return "<a href='" + d.image_url + "' target='_blank'>" + d.image_url + "</a>";
}
},
{
field: 'banner_url',
title: 'banner跳转链接',
templet: function(d){
return "<a href='"+d.banner_url+"' target='_blank'>"+d.banner_url+"</a>";
templet: function (d) {
return "<a href='" + d.banner_url + "' target='_blank'>" + d.banner_url + "</a>";
}
},
{
......@@ -96,14 +97,17 @@
},
]],
});
table.on('tool(table1)', function(obj) {
table.on('tool(table1)', function (obj) {
var data = obj.data;
var event = obj.event;
if (event === 'del') {
var index = layer.confirm("确认删除?", {icon: 3, title: '删除'}, function () {
$.get('/admin/application-category/delete-banner', {id: data.id,applicate_category_id:applicate_category_id}, function (rev) {
$.get('/admin/application-category/delete-banner', {
id: data.id,
applicate_category_id: applicate_category_id
}, function (rev) {
layer.msg(rev.msg);
if (0==rev.code) {
if (0 == rev.code) {
table.reload('table1');
}
});
......@@ -118,11 +122,11 @@
type: 1,
content: $("#_form"),
btn: ['保存', '取消'],
success: function() {
success: function () {
clearForm();
},
btn1: function() {
$.post('/admin/application-category/add-banner', $("#form1").serialize(), function(rev) {
btn1: function () {
$.post('/admin/application-category/add-banner', $("#form1").serialize(), function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
layer.close(index);
......@@ -131,12 +135,12 @@
}
});
},
btn2: function() {
btn2: function () {
layer.close(index);
clearForm();
$("#_form").css('display', 'none');
},
cancel: function() {
cancel: function () {
layer.close(index);
clearForm();
$("#_form").css('display', 'none');
......@@ -148,24 +152,25 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
before: function(input){
var data = {};
data._csrf = $_csrf;
data.image_type = 5;
this.data=data;
url: '/admin/oss/upload',
before: function (input) {
var data = {};
data._csrf = $_csrf;
data.image_type = 'h5_banner';
this.data = data;
},
done: function (res) {
if(res.code == 0){
if (res.code == 0) {
$("input[name='image']").val(res.data.image_id);
$("#image1").attr('src', res.data.image_src);
$("#image1").attr('src', res.data.src);
}
},
error: function (res) {
}
});
function clearForm(){
function clearForm() {
form.val("form1", {
image: '',
});
......
......@@ -93,12 +93,12 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data: {_csrf: $_csrf},
url: '/admin/oss/upload',
data: {_csrf: $_csrf, image_type: 'coin'},
done: function (res) {
if(res.code == 0){
$("input[name='icon']").val(res.data.image_id);
$("#icon1").attr('src', res.data.image_src);
$("#icon1").attr('src', res.data.src);
}
},
error: function (res) {
......@@ -108,12 +108,12 @@
uploader.render({
elem: "#upload2",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:2},
url: '/admin/oss/upload',
data: {_csrf: $_csrf, image_type: 'banner'},
done: function (res) {
if(res.code == 0){
$("input[name='banner']").val(res.data.image_id);
$("#icon2").attr('src', res.data.image_src);
$("#icon2").attr('src', res.data.src);
}
},
error: function (res) {
......
......@@ -72,7 +72,7 @@
<div class="layui-form-item">
<label class="layui-form-label">类型</label>
<div class="layui-input-block">
<select name="type" >
<select name="type">
<option value="1">非原生页面</option>
<option value="2">原生页面</option>
</select>
......@@ -164,7 +164,7 @@
<div class="layui-form-item">
<label class="layui-form-label">跳转方式</label>
<div class="layui-input-block">
<select name="redirect_type" >
<select name="redirect_type">
<option value="1">跳转应用详情</option>
<option value="2">直接跳转h5</option>
</select>
......@@ -174,7 +174,7 @@
<div class="layui-form-item">
<label class="layui-form-label">H5打开方式(PC版)</label>
<div class="layui-input-block">
<select name="open_type" >
<select name="open_type">
<option value="0">选择打开方式</option>
<option value="1">钱包内打开</option>
<option value="2">浏览器打开</option>
......@@ -185,8 +185,8 @@
<div class="layui-form-item">
<label class="layui-form-label">H5打开方式(APP版)</label>
<div class="layui-input-block">
<select name="open_type_app" >
<option value="0" >选择打开方式</option>
<select name="open_type_app">
<option value="0">选择打开方式</option>
<option value="1">钱包内打开</option>
<option value="2">浏览器打开</option>
</select>
......@@ -195,7 +195,7 @@
<div class="layui-form-item">
<label class="layui-form-label">所属类型</label>
<div class="layui-input-block">
<select name="platform_type" >
<select name="platform_type">
<option value="1">币钱包</option>
<option value="2">托管账户</option>
<option value="3">通用</option>
......@@ -218,12 +218,12 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data: {_csrf: $_csrf},
url: '/admin/oss/upload',
data: {_csrf: $_csrf, image_type: 'coin'},
done: function (res) {
if(res.code == 0){
if (res.code == 0) {
$("input[name='icon']").val(res.data.image_id);
$("#icon1").attr('src', res.data.image_src);
$("#icon1").attr('src', res.data.src);
}
},
error: function (res) {
......@@ -233,12 +233,12 @@
uploader.render({
elem: "#upload2",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:4},
url: '/admin/oss/upload',
data: {_csrf: $_csrf, image_type: 'h5_icon'},
done: function (res) {
if(res.code == 0){
if (res.code == 0) {
$("input[name='h5_icon']").val(res.data.image_id);
$("#icon2").attr('src', res.data.image_src);
$("#icon2").attr('src', res.data.src);
}
},
error: function (res) {
......@@ -248,12 +248,12 @@
uploader.render({
elem: "#upload3",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:4},
url: '/admin/oss/upload',
data: {_csrf: $_csrf, image_type: 'h5_icon'},
done: function (res) {
if(res.code == 0){
if (res.code == 0) {
$("input[name='introduce_image']").val(res.data.image_id);
$("#icon3").attr('src', res.data.image_src);
$("#icon3").attr('src', res.data.src);
}
},
error: function (res) {
......
This diff is collapsed.
......@@ -187,22 +187,22 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
url: '/admin/oss/upload',
before: function(input){
var data = {};
var image_category = $('#image_category').val();
data._csrf = $_csrf;
if(image_category == 1 ){
data.image_type = 3 ;
data.image_type = 'application' ;
}else if(image_category == 2){
data.image_type = 6 ;;
data.image_type = 'h5_application';
}
this.data=data;
},
done: function (res) {
if(res.code == 0){
$("input[name='image']").val(res.data.image_id);
$("#image1").attr('src', res.data.image_src);
$("#image1").attr('src', res.data.src);
}
},
error: function (res) {
......
......@@ -22,7 +22,7 @@
</div>
<div class="layui-row add" style="display: none;padding: 5px;" id="_form">
<div class="layui-col-xs6 layui-col-sm6 layui-col-md11">
<form class="layui-form" action="javascript:void(0)" id="form1" method="post" lay-filter="form1">
<form class="layui-form" action="javascript:void(0)" id="form1" method="post" lay-filter="form1">
<input type="hidden" name="_csrf" value="<?= Yii::$app->request->getCsrfToken() ?>">
<div class="layui-form-item">
<div class="layui-inline">
......@@ -69,15 +69,15 @@
{
field: 'banner_url',
title: 'banner跳转地址',
templet: function(d){
return "<a href='"+d.banner_url+"' target='_blank'>"+d.banner_url+"</a>";
templet: function (d) {
return "<a href='" + d.banner_url + "' target='_blank'>" + d.banner_url + "</a>";
}
},
{
field: 'image_url',
title: '图片跳转地址',
templet: function(d){
return "<a href='"+d.image_url+"' target='_blank'>"+d.image_url+"</a>";
templet: function (d) {
return "<a href='" + d.image_url + "' target='_blank'>" + d.image_url + "</a>";
},
width: 600
},
......@@ -92,14 +92,14 @@
var form = layui.form;
form.render();
table.on('tool(table1)', function(obj) {
table.on('tool(table1)', function (obj) {
var event = obj.event;
var data = obj.data;
if (event === 'del') {
var index = layer.confirm("确认删除?", {icon: 3, title: '删除'}, function () {
$.get('/admin/coin-banner/delete', {id: data.id}, function (rev) {
layer.msg(rev.msg);
if (0==rev.code) {
if (0 == rev.code) {
table.reload('table1');
}
});
......@@ -115,11 +115,11 @@
type: 1,
content: $("#_form"),
btn: ['保存', '取消'],
success: function() {
success: function () {
clearForm();
},
btn1: function() {
$.post('/admin/coin-banner/add', $("#form1").serialize(), function(rev) {
btn1: function () {
$.post('/admin/coin-banner/add', $("#form1").serialize(), function (rev) {
layer.msg(rev.msg);
if (0 == rev.code) {
layer.close(index);
......@@ -129,35 +129,36 @@
}
});
},
btn2: function() {
btn2: function () {
layer.close(index);
$("#_form").css('display', 'none');
},
cancel: function() {
cancel: function () {
layer.close(index);
$("#_form").css('display', 'none');
}
});
})
function clearForm(){
function clearForm() {
form.val("form1", {
image_url: '',
banner_url: ''
});
$("#icon1").attr('src', '');
}
//图片上传
var uploader = layui.upload;
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:2},
url: '/admin/oss/upload',
data: {_csrf: $_csrf, image_type: 'banner'},
done: function (res) {
if(res.code == 0){
$("input[name='image_url']").val(res.data.image_src);
$("#icon1").attr('src', res.data.image_src);
if (res.code == 0) {
$("input[name='image_url']").val(res.data.src);
$("#icon1").attr('src', res.data.src);
}
},
error: function (res) {
......
......@@ -137,12 +137,12 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data: {_csrf: $_csrf,image_type:2},
url: '/admin/oss/upload',
data: {_csrf: $_csrf,image_type: 'banner'},
done: function (res) {
if(res.code == 0){
$("input[name='image_url']").val(res.data.image_src);
$("#icon1").attr('src', res.data.image_src);
$("input[name='image_url']").val(res.data.src);
$("#icon1").attr('src', res.data.src);
}
},
error: function (res) {
......
......@@ -180,7 +180,7 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/coin/upload',
url: '/admin/oss/upload',
data: {_csrf: $_csrf},
done: function (res) {
console.log(res.data.src);
......
......@@ -183,7 +183,7 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/coin/upload',
url: '/admin/oss/upload',
data: {_csrf: $_csrf},
done: function (res) {
console.log(res.data.src);
......
......@@ -56,12 +56,12 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data:{_csrf:$_csrf,image_type:7},
url: '/admin/oss/upload',
data:{_csrf:$_csrf,image_type:'platform_icon'},
done: function (res) {
if(res.code == 0){
$("input[name='image']").val(res.data.image_src);
$("#image1").attr('src', res.data.image_src);
$("input[name='image']").val(res.data.src);
$("#image1").attr('src', res.data.src);
}
},
error: function (res) {
......
......@@ -43,7 +43,7 @@
<div class="layui-inline">
<label class="layui-form-label">图片</label>
<div class="layui-input-block">
<img src="" style="margin-top: 11px; max-width: 32px; max-height: 32px" id="icon1">
<img src="<?= $model->image_url ?>" style="margin-top: 11px; max-width: 32px; max-height: 32px" id="icon1">
</div>
<input type="hidden" name="image_url" value="" lay-verify="required|image_url">
</div>
......@@ -67,12 +67,12 @@
$_csrf = $("input[name='_csrf']").val();
uploader.render({
elem: "#upload1",
url: '/admin/image/upload',
data: {_csrf: $_csrf, image_type: 2},
url: '/admin/oss/upload',
data: {_csrf: $_csrf, image_type: 'banner'},
done: function (res) {
if (res.code == 0) {
$("input[name='image_url']").val(res.data.image_src);
$("#icon1").attr('src', res.data.image_src);
$("input[name='image_url']").val(res.data.src);
$("#icon1").attr('src', res.data.src);
}
},
error: function (res) {
......
......@@ -65,10 +65,10 @@ form.render();
var index_upload = 0;
upload.render({
elem: '#upload1',
url: '/admin/app/upload',
url: '/admin/oss/upload',
accept: 'file',
field: 'apk',
data: {_csrf: $('input[name="_csrf"]').val()},
field: 'file',
data: {_csrf: $('input[name="_csrf"]').val(), image_type: 'app'},
before: function (obj) {
index_upload = layer.load(1);
},
......@@ -76,7 +76,7 @@ upload.render({
layer.close(index_upload);
layer.msg(res.msg);
if (0 == res.code) {
$('input[name="download_url"]').val(res.path);
$('input[name="download_url"]').val(res.data.src);
}
}
});
......
This diff is collapsed.
......@@ -98,7 +98,7 @@ class ExchangeBusiness
goto doEnd;
}
if (strtoupper($tag) == 'GM' || strtoupper($tag) == 'BSTC' || strtoupper($tag) == 'RYH' || strtoupper($tag) == 'CNDT' || strtoupper($tag) == 'WL' || strtoupper($tag) == 'ETS' || strtoupper($tag) == 'LIMS' || strtoupper($tag) == 'AT' || strtoupper($tag) == 'BTJ') {
if (strtoupper($tag) == 'STO' || strtoupper($tag) == 'GM' || strtoupper($tag) == 'BSTC' || strtoupper($tag) == 'RYH' || strtoupper($tag) == 'CNDT' || strtoupper($tag) == 'WL' || strtoupper($tag) == 'ETS' || strtoupper($tag) == 'LIMS' || strtoupper($tag) == 'AT' || strtoupper($tag) == 'BTJ') {
$quotation = [
'low' => 0,
'high' => 0,
......
......@@ -55,7 +55,7 @@ class CoinApplication extends BaseActiveRecord
$recommendItems = CoinApplicateRecommend::getRecommendItemsByType(2);
foreach($data as $key => &$value){
if($value['icon']){
$value['icon_url'] = $icon_Infos[$value['icon']]['base_url'].$icon_Infos[$value['icon']]['file_url'];
$value['icon_url'] = Yii::$app->params['service']['OssService']['url'].$icon_Infos[$value['icon']]['file_url'];
}else{
$value['icon_url'] = '';
}
......@@ -100,7 +100,7 @@ class CoinApplication extends BaseActiveRecord
$recommendItems = CoinApplicateRecommend::getRecommendItemsByType(2);
foreach($data as $key => &$value){
if($value['icon']){
$value['icon_url'] = isset($icon_Infos[$value['icon']]) ? $icon_Infos[$value['icon']]['base_url'].$icon_Infos[$value['icon']]['file_url'] : '';
$value['icon_url'] = isset($icon_Infos[$value['icon']]) ? Yii::$app->params['service']['OssService']['url'].$icon_Infos[$value['icon']]['file_url'] : '';
}else{
$value['icon_url'] = '';
}
......
......@@ -63,12 +63,12 @@ class CoinApplicationCategory extends BaseActiveRecord
$recommendItems = CoinApplicateRecommend::getRecommendItemsByType(1);
foreach($data as $key => &$value){
if($value['icon']){
$value['icon_url'] = $icon_Infos[$value['icon']]['base_url'].$icon_Infos[$value['icon']]['file_url'];
$value['icon_url'] = Yii::$app->params['service']['OssService']['url'].$icon_Infos[$value['icon']]['file_url'];
}else{
$value['icon_url'] = '';
}
if($value['banner']){
$value['banner_image_url'] = $icon_Infos[$value['banner']]['base_url'].$icon_Infos[$value['banner']]['file_url'];
$value['banner_image_url'] = Yii::$app->params['service']['OssService']['url'].$icon_Infos[$value['banner']]['file_url'];
}else{
$value['banner_image_url'] = '';
}
......
......@@ -35,7 +35,7 @@ class CoinBanner extends BaseActiveRecord
$image_id_items = array_column($data,'image_id');
$image_info = CoinImage::getItemsByIds($image_id_items);
foreach ($data as &$value){
$value['image_url'] = $image_info[$value['image_id']]['base_url'].$image_info[$value['image_id']]['file_url'];
$value['image_url'] = Yii::$app->params['service']['OssService']['url'].$image_info[$value['image_id']]['file_url'];
}
return ['code' => 0,'data' => $data];
}else{
......
......@@ -8,6 +8,7 @@
namespace common\models\psources;
use Yii;
class CoinImage extends BaseActiveRecord
......@@ -18,10 +19,9 @@ class CoinImage extends BaseActiveRecord
}
public static function addOneRecord($base_url,$file_path)
public static function addOneRecord($file_path)
{
$coin_image = new self();
$coin_image->base_url = $base_url;
$coin_image->file_url = $file_path;
$coin_image->save();
return $coin_image->id;
......@@ -29,8 +29,8 @@ class CoinImage extends BaseActiveRecord
public static function getItemsByIds($idItems)
{
$data = self::find()->where(['in','id',$idItems])->asArray()->all();
return array_column($data,null,'id');
$data = self::find()->where(['in', 'id', $idItems])->asArray()->all();
return array_column($data, null, 'id');
}
public static function getItemById($id)
......@@ -40,19 +40,19 @@ class CoinImage extends BaseActiveRecord
public static function getItemsByImageIds($image_ids)
{
if($image_ids) {
if(is_array($image_ids)){
if ($image_ids) {
if (is_array($image_ids)) {
$idItems = $image_ids;
}else {
$idItems = explode(',',$image_ids);
} else {
$idItems = explode(',', $image_ids);
}
$data = self::find()->where(['in','id',$idItems])->asArray()->all();
foreach ($data as &$value){
$value['image_url'] = $value['base_url'].$value['file_url'];
$data = self::find()->where(['in', 'id', $idItems])->asArray()->all();
foreach ($data as &$value) {
$value['image_url'] = Yii::$app->params['service']['OssService']['url'] . $value['file_url'];
}
return ['code' => 0,'data' => $data];
}else{
return ['code' => 0,'data' => []];
return ['code' => 0, 'data' => $data];
} else {
return ['code' => 0, 'data' => []];
}
}
......
......@@ -15,6 +15,8 @@ class BinanceBuilder extends FactoryService
protected $base_url = 'https://api.binance.com';
protected $supported_symbol = 'supported_symbol_binance';
protected $supported_symbol_list = 'supported_symbol_binance_list';
protected $supported_symbol_close_sort_list = 'supported_symbol_close_sort_binance_list';
protected $supported_symbol_change_sort_list = 'supported_symbol_change_sort_binance_list';
protected $quotation_prefix = 'quotation_binance_';
public function getTicker()
......@@ -57,7 +59,7 @@ class BinanceBuilder extends FactoryService
public function getTickerFromCache($page = 1)
{
$size = 0;
for ($i = 0; $i < $page; $i ++) {
for ($i = 0; $i < $page; $i++) {
$size += 50;
$this->end = $size;
}
......@@ -105,10 +107,43 @@ class BinanceBuilder extends FactoryService
$data = [
'ticker' => $ticker,
'page' => [
'pageSize' => 50,
'pageSize' => 50,
'currentPage' => (int)$page,
]
];
return ['code' => $this->code, 'data' => $data];
}
public function TickerSort()
{
$len = $this->redis->llen($this->supported_symbol_list);
$ticker = [];
for ($i = 0; $i < $len; $i++) {
$symbol = $this->redis->lindex($this->supported_symbol_list, $i);
list($close, $open) = $this->redis->hmget($this->quotation_prefix . strtolower($symbol), 'last', 'open');
$temp = [];
$temp['symbol'] = strtoupper($symbol);
$temp['close'] = number_format($close, 6, '.', '');
$temp['change'] = (0 == $open) ? 0 : (float)sprintf("%0.4f", ($close - $open) / $open * 100);
array_push($ticker, $temp);
}
$ticker_sort_close= $this->arraySort($ticker,'close');
foreach ($ticker_sort_close as $val) {
$this->redis->lpush($this->supported_symbol_close_sort_list, $val['symbol']);
}
$ticker_change_close= $this->arraySort($ticker,'change');
foreach ($ticker_change_close as $val) {
$this->redis->lpush($this->supported_symbol_change_sort_list, $val['symbol']);
}
}
protected function arraySort($array, $keys, $sort = SORT_DESC)
{
$keysValue = [];
foreach ($array as $k => $v) {
$keysValue[$k] = $v[$keys];
}
array_multisort($keysValue, $sort, $array);
return $array;
}
}
\ No newline at end of file
......@@ -15,6 +15,8 @@ class HuobiBuilder extends FactoryService
protected $base_url = 'https://api.huobi.pro';
protected $supported_symbol = 'supported_symbol_huobi';
protected $supported_symbol_list = 'supported_symbol_huobi_list';
protected $supported_symbol_close_sort_list = 'supported_symbol_close_sort_huobi_list';
protected $supported_symbol_change_sort_list = 'supported_symbol_change_sort_huobi_list';
protected $quotation_prefix = 'quotation_huobi_';
public function getTicker()
......@@ -111,6 +113,38 @@ class HuobiBuilder extends FactoryService
];
return ['code' => $this->code, 'data' => $data];
}
public function TickerSort()
{
$len = $this->redis->llen($this->supported_symbol_list);
$ticker = [];
for ($i = 0; $i < $len; $i++) {
$symbol = $this->redis->lindex($this->supported_symbol_list, $i);
list($close, $open) = $this->redis->hmget($this->quotation_prefix . strtolower($symbol), 'last', 'open');
$temp = [];
$temp['symbol'] = strtoupper($symbol);
$temp['close'] = number_format($close, 6, '.', '');
$temp['change'] = (0 == $open) ? 0 : (float)sprintf("%0.4f", ($close - $open) / $open * 100);
array_push($ticker, $temp);
}
$ticker_sort_close= $this->arraySort($ticker,'close');
foreach ($ticker_sort_close as $val) {
$this->redis->lpush($this->supported_symbol_close_sort_list, $val['symbol']);
}
$ticker_change_close= $this->arraySort($ticker,'change');
foreach ($ticker_change_close as $val) {
$this->redis->lpush($this->supported_symbol_change_sort_list, $val['symbol']);
}
}
protected function arraySort($array, $keys, $sort = SORT_DESC)
{
$keysValue = [];
foreach ($array as $k => $v) {
$keysValue[$k] = $v[$keys];
}
array_multisort($keysValue, $sort, $array);
return $array;
}
public function getHotTicker()
{
......
......@@ -13,6 +13,11 @@ use linslin\yii2\curl\Curl;
class ZhaobiBuilder extends FactoryService
{
protected $base_url = 'https://api.biqianbao.top';
protected $supported_symbol = 'supported_symbol_zhaobi';
protected $supported_symbol_list = 'supported_symbol_zhaobi_list';
protected $supported_symbol_close_sort_list = 'supported_symbol_close_sort_zhaobi_list';
protected $supported_symbol_change_sort_list = 'supported_symbol_change_sort_zhaobi_list';
protected $quotation_prefix = 'quotation_zhaobi_';
public function getTickerFromCache()
{
......@@ -61,6 +66,35 @@ class ZhaobiBuilder extends FactoryService
return ['code' => $this->code, 'data' => $data];
}
public function TickerSort()
{
$keys = $this->redis->smembers($this->supported_symbol);
if (false == $this->redis->exists($this->supported_symbol_list)) {
foreach ($keys as $val) {
$this->redis->lpush($this->supported_symbol_list, $val);
}
}
$len = $this->redis->llen($this->supported_symbol_list);
$ticker = [];
for ($i = 0; $i < $len; $i++) {
$symbol = $this->redis->lindex($this->supported_symbol_list, $i);
list($close, $open) = $this->redis->hmget($this->quotation_prefix . strtolower($symbol), 'last', 'open');
$temp = [];
$temp['symbol'] = strtoupper($symbol);
$temp['close'] = number_format($close, 6, '.', '');
$temp['change'] = (0 == $open) ? 0 : (float)sprintf("%0.4f", ($close - $open) / $open * 100);
array_push($ticker, $temp);
}
$ticker_sort_close= $this->arraySort($ticker,'close');
foreach ($ticker_sort_close as $val) {
$this->redis->lpush($this->supported_symbol_close_sort_list, $val['symbol']);
}
$ticker_change_close= $this->arraySort($ticker,'change');
foreach ($ticker_change_close as $val) {
$this->redis->lpush($this->supported_symbol_change_sort_list, $val['symbol']);
}
}
public function getNotice($params = [])
{
$curl = new Curl();
......@@ -90,6 +124,15 @@ class ZhaobiBuilder extends FactoryService
];
}
return ['code' => $this->code, 'notice' => $data];
}
protected function arraySort($array, $keys, $sort = SORT_DESC)
{
$keysValue = [];
foreach ($array as $k => $v) {
$keysValue[$k] = $v[$keys];
}
array_multisort($keysValue, $sort, $array);
return $array;
}
}
\ No newline at end of file
......@@ -23,11 +23,9 @@
"yiisoft/yii2-queue": "~2.0",
"linslin/yii2-curl": "*",
"voku/simple_html_dom": "^4.5",
<<<<<<< HEAD
"yiisoft/yii2-elasticsearch": "~2.0.0"
=======
"workerman/workerman": "^3.5"
>>>>>>> master
"yiisoft/yii2-elasticsearch": "~2.0.0",
"workerman/workerman": "^3.5",
"aliyuncs/oss-sdk-php": "^2.3"
},
"require-dev": {
"yiisoft/yii2-debug": "~2.0.0",
......
......@@ -4,9 +4,50 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "81ec58b7ecb4528b2f48761c31829869",
"content-hash": "b4597476a86922ec3d1494465523a1e8",
"packages": [
{
"name": "aliyuncs/oss-sdk-php",
"version": "v2.3.0",
"source": {
"type": "git",
"url": "https://github.com/aliyun/aliyun-oss-php-sdk.git",
"reference": "e69f57916678458642ac9d2fd341ae78a56996c8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/e69f57916678458642ac9d2fd341ae78a56996c8",
"reference": "e69f57916678458642ac9d2fd341ae78a56996c8",
"shasum": ""
},
"require": {
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "~1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"OSS\\": "src/OSS"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Aliyuncs",
"homepage": "http://www.aliyun.com"
}
],
"description": "Aliyun OSS SDK for PHP",
"homepage": "http://www.aliyun.com/product/oss/",
"time": "2018-01-08T06:59:35+00:00"
},
{
"name": "bower-asset/bootstrap",
"version": "v3.3.7",
"source": {
......@@ -2234,6 +2275,55 @@
"time": "2018-07-05T15:44:47+00:00"
},
{
"name": "yiisoft/yii2-elasticsearch",
"version": "2.0.5",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-elasticsearch.git",
"reference": "82d66d17543040dda3c64f299ae251658156c2c1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii2-elasticsearch/zipball/82d66d17543040dda3c64f299ae251658156c2c1",
"reference": "82d66d17543040dda3c64f299ae251658156c2c1",
"shasum": ""
},
"require": {
"ext-curl": "*",
"yiisoft/yii2": "~2.0.14"
},
"type": "yii2-extension",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"yii\\elasticsearch\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Carsten Brandt",
"email": "mail@cebe.cc"
}
],
"description": "Elasticsearch integration and ActiveRecord for the Yii framework",
"keywords": [
"active-record",
"elasticsearch",
"fulltext",
"search",
"yii2"
],
"time": "2018-03-20T11:34:58+00:00"
},
{
"name": "yiisoft/yii2-queue",
"version": "2.1.0",
"source": {
......
<?php
namespace console\controllers;
use common\business\Chain33Business;
use common\models\psources\CoinGameBet;
use common\service\chain33\Chain33Service;
use common\service\exchange\ExchangeBuilderFactory;
use yii\console\Controller;
use Yii;
class TickerSortController extends Controller
{
/**
* 行情排序
*/
public function actionIndex()
{
$class = ['Binance', 'Huobi', 'Zhaobi'];
foreach ($class as $val) {
go(function () use ($val) {
\Co::sleep(0.5);
$ticker_builder = ExchangeBuilderFactory::create($val);
$ticker_builder->TickerSort();
});
}
}
}
\ No newline at end of file
coverage_clover: coverage.xml
json_path: coverage.json
vendor
composer.lock
doc
output
.idea
.buildpath
.project
.settings
language: php
php:
- 7.1
- 7.0
- 5.6
- 5.5
- 5.4
install:
- composer self-update
- composer install --no-interaction
script:
- php vendor/bin/phpunit
after_success:
- php vendor/bin/coveralls -v
env:
global:
- secure: SzmQ854lQmhV6ZkAG7lQNTY3CkazrXnDSb6VMwPU/sdaLGxPO159AW3fJS5d0sO/XN1P8x5WNkoA4i9soDlLBRibEEISNUM/2EMnpszsRymZ9o97PrS2IgORXTUL/OF+rpATzyNVB2p+2l9hBLiGf17exMSA5iOeY7W6E+VKPGi8TFykgbGUnLKU0h1hV3rzmtfGjOXcSpvYU/hxeZD/J/+6m5Gic9b/pNS+AbfTj7Y7Ru9tNsnyUP29V/vtEYtpQir3ZxQiSiUv9idybgGnJBOMYydJofb/mpFYHhYLSWqtMKGNLpeawmqs4z8S1Tvx5U5uzW5+h/mpzhvBaFlWGpm8t89BQxun5LVX5NiYCrV7TqaLitGp1cSpMjMDnrnSTNzk1exVz+rWZZcWS7yB9ULYA681GA8StXWk167qB7Y30iK1dFK3+2mDN2cEY+qLs8+bupDowQ4eOM+eqfhxX8F8+ouKcKomETsjiIwL+CUsIe6wjvnYFWb1YlRhbsI75bblHApflohnt6gVSJ78ZPqID+u2oUMjmIWXLTnRR2Y2tgEW8uqHeIoQ8BBntLdQDmv0BO4FpnGQIwrUUwQYeNzEM0DOr3hWZhyDR6Xvl+9H0l52xjANaSqpuTZfC3zmeFTG7kIjydvxNePRrony6XAawL9BvI7aKWuVF6YVjPM=
- secure: nEhsU8aUQqsAJeuger+boh51oTpeo4YNG7vUWbKxdwVDIrcLb+l7r7RvTlxU7mt8IZTWwicgri18mh+Wi04BwX4ulBA1SCs8jPbL51KEo5izoDGGtLSd2fuPHdslYSrwagrvq90EPnDT/7fHWn/TAoT+rueZzjNyCu5IGSgL3GnXaUThsJ82NMePL2YRdP4Q1qmtZPRFBOkOQ6F0heuV8fw8sLyTO3txaCQum9YneGxrWxOl/E8zB0qtlnPwLE8ogaHZMQh2/jThmTbI5UqwRTxV4f0qoD5eJYH+j0fslsSAjsg/HPnSuVcnccK3zSU+s2sV4dPCcISzECJvZEObwipfxOGhdqt5gMcxHhn8qVsbT97iIh106pG/BJCDgQd2EeVW8WfCi6cCuCKIMipvVkMypkmjQHWU1XaqPzILl7g5diW9Ctp2C4Akq5dYdrdu8IrnVK1ShtkQVaWU+S/Bht8VU5gYP7olPW/GdTz7sceU1NOIC4NPXqmWKbfavR98U5dkHMLMvzABYL1Q87h+KhPD1c14NUyw3YENUW7REiF/X5lERRm5H0kJ/1JqAa+AgeHQEGmPVuZV2s/na4b0S1479QRVmSM/6ZzXQpU+Y8jCRfETpUFA4S331369kirHgCqDlxyIntuEKrzivD02/O+5C3eJ0WHRz6QsN2/R4qg=
- secure: ZTvzNXEZP4efl+a/3VGMmdabfUQp83v5/lecMns039Ro7UuZYPdtbPtpPnpjaTI6Htd22A4Rva5BU/3JCQJAyQvpbKNn5sGou2SmfQu3o0SyhggSB7gWjYAf707aW1j4bHYfP8IjDS5NjuVk3AqXeNSUuLRUXRmwSOB0lSYiRhiTJY+pUdBl382Hx4NbhIU/gmOzRoJCs7coTip8IURXYEHPi5dnDWluajxI+TgNXFccSgEleeQDJajYgXmpLb2EhSj8piipOnVgaCEE5bh5fbp32024Qq38SGHKcbfnwj2IInpZpZESJknRKoqAlFjdOJhork82dBcvAr5JxCBZKx5IuwXcTjxkQ6tRtBeqhPLPFuX3MQ8WrtU+wniPM0RCH/VoFkUKO7JGQDwmoi2AKago4PsuDs4P6Y6CeuOVpcso731GwwMNhIJcyrJJivXprQNEGsEw+9wLjU1qNYs6IIA3S/gPzFrNbdX5Wf8vxt0vLpgYvBNtPnLMejMtknuyfVzf5iKuVVoGPDTEz+ajs06+jfoPfm/4sLTaLghuVH7Adm74OpF769JQNnQYKwJuu4bNlcbLJChulCEMBOx7myqo/9O6RCTuqzHaGmVWNot4RGqRFHgJGl/JJf0WpAVitbhbRH3kGoyKb6jFM74CJbPsE7OORlJLDC3cdD3C8Pk=
- secure: Qr5NR4CVzBKCQgRgMH0x772TPJ1+brx3UCvtRNu8fi4j3p8bz+HDMjBaBDSFmEB09nunLI55/8mj88/5GXmnpFs8+CPTkcW+QZOcxg3cxpI4SNmxoB12/ZawlFHAqSUaRRE7RUWVkY3KL8tIGjEZcFyUBQ1DVNX3OMpiKs3NLtHa7oUIknyBxdSokm4kpLhSXYe7WmO0vhuZbMZE0S1EISToiBS6AdhGUEbTLJ/vNsIDY07fu6+Vh3HxVbyUFPqUZGlkZpQ+2xMJ3kiqPBMrXtRF/IhhPjORDil6Ns9SQ8/AAlaCddvYvRaT4Pjv2/aX+t3l28qI1qmryPtWXpce5UXecWGYqdRpSJc6Y/pEt4m4FeeGoEFWnSPGIs7FRmeiis8q2rojGZ18i4vI/k4iHmqEBnTlMp3SWnRb9L1adJ8ZAWln8aC88gkQXm67w7+1CxLycerbYj9H1ugqHENuHcxv4uHUcZgEENX3EWatu8i9+K2IUuU/2zcmpu7qtsziYcoyW8DOOmYpJfXGMLtmF9+pqp/Tp6i0tltFSEfmY3N8o7xvv3enLvFHsjL+3ElFdd1blUPSrvZJHgA9M3lJ+QF1RJZCpJqgPlQ0XOZK1Bf4P46zpEj01wKaK4JQrkLPRXhbBOuIJn5O6WlFJyPX4+SaBfwTzb4AvM4aUg2TgTg=
- secure: Inw5ftA8fxvhMHRZwoZzATxn4WICJsCq7ZX4y2gI+b/8u0JQIsbLgY9WTYV+XdSxOoNwuVa1oUxEWI0aDORtXKC3XaIXXKrwndag0zxS77JEYwWvQsjM7BhEbF7MF7MYk8rRXpn6mbfGAT/NfqEOx91RCY8UKeMzD0oPkpkBnJ9Ekuod6JBBq+7j3v4mYUItA8pxvw7b4Pdd4z2xzjgOwNhJYMOCpts50DWZI+WXj0HvTYaMXe5mJJtORK5lsr0a9cbsBqAzE6l+3zGI8XkgHn130ux5XH3DE7hZBeti3ZNaO3d2Vv+496/1EObG0rSFk+z3dmNKqjMz4nh3bYIkdLMegwmgCWs2mvQhkwYhzmnPRHVSERrgZjSWnuKn2PKnBar6tui9KaLNgpo2j3jWpwMLJ3bGAfE5JtMppxAxNqj/q+YB2UZo7Mn7EDjkTDjgxCuazTJwWqH7xxCOykWPABBI17P3JaOXQJEK39LavpfSMm3kdmU0ocpUs7FniLuFm6xL71VxY1wHG10yskczEcFHZ3iyIyGM+xum4vbt5y6Yg+zfdExYQsbrxHDDZ3HbHY3tEU0WhM55vrC42NIXRWqXqJ8OAxpl4nivfx96eoBAThiUU9xXtZmh7WRFVYsstoGtxZwfk5+bi+oeVO9kih4xabwbgHgL9BTc1TR1C4U=
# ChangeLog - Aliyun OSS SDK for PHP
## v2.3.0 / 2018-01-05
* 修复:putObject支持创建空文件
* 修复:createBucket支持IA/Archive
* 增加:支持restoreObject
* 增加:支持Symlink功能
* 增加:支持getBucketLocation
* 增加:支持getBucketMeta
* 增加:支持代理服务器Proxy
## v2.2.4 / 2017-04-25
* fix getObject to local file bug
## v2.2.3 / 2017-04-14
* fix md5 check
## v2.2.2 / 2017-01-18
* 解决在php7上运行连接数和内存bug
## v2.2.1 / 2016-12-01
* 禁止http curl自动填充Accept-Encoding
## v2.2.0 / 2016-11-22
* 修复PutObject/CompleteMultipartUpload的返回值问题(#26)
## v2.1.0 / 2016-11-12
* 增加[RTMP](https://help.aliyun.com/document_detail/44297.html)接口
* 增加支持[图片服务](https://help.aliyun.com/document_detail/44686.html)
## v2.0.7 / 2016-06-17
* Support append object
## v2.0.6
* Trim access key id/secret and endpoint
* Refine tests and setup travis CI
## v2.0.5
* 增加Add/Delete/Get BucketCname接口
## v2.0.4
* 增加Put/Get Object Acl接口
## v2.0.3
* 修复Util中的常量定义在低于5.6的PHP版本中报错的问题
## v2.0.2
* 修复multipart上传时无法指定Content-Type的问题
## v2.0.1
* 增加对ListObjects/ListMultipartUploads时特殊字符的处理
* 提供接口获取OssException中的详细信息
## 2015.11.25
* **大版本升级,不再兼容以前接口,新版本对易用性做了很大的改进,建议用户迁移到新版本。**
## 修改内容
* 不再支持PHP 5.2版本
### 新增内容
* 引入命名空间
* 接口命名修正,采用驼峰式命名
* 接口入参修改,把常用参数从Options参数中提出来
* 接口返回结果修改,对返回结果进行处理,用户可以直接得到容易处理的数据结构 
* OssClient的构造函数变更
* 支持CNAME和IP格式的Endpoint地址
* 重新整理sample文件组织结构,使用function组织功能点
* 增加设置连接超时,请求超时的接口
* 去掉Object Group相关的已经过时的接口
* OssException中的message改为英文
### 问题修复
* object名称校验不完备
#The MIT License (MIT)
Copyright (c) ali-sdk and other contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
# Aliyun OSS SDK for PHP
[![Latest Stable Version](https://poser.pugx.org/aliyuncs/oss-sdk-php/v/stable)](https://packagist.org/packages/aliyuncs/oss-sdk-php)
[![Build Status](https://travis-ci.org/aliyun/aliyun-oss-php-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-php-sdk)
[![Coverage Status](https://coveralls.io/repos/github/aliyun/aliyun-oss-php-sdk/badge.svg?branch=master)](https://coveralls.io/github/aliyun/aliyun-oss-php-sdk?branch=master)
## [README of English](https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/README.md)
## 概述
阿里云对象存储(Object Storage Service,简称OSS),是阿里云对外提供的海量、安全、低成本、高可靠的云存储服务。用户可以通过调用API,在任何应用、任何时间、任何地点上传和下载数据,也可以通过用户Web控制台对数据进行简单的管理。OSS适合存放任意文件类型,适合各种网站、开发企业及开发者使用。
## 运行环境
- PHP 5.3+
- cURL extension
提示:
- Ubuntu下可以使用apt-get包管理器安装php的cURL扩展 `sudo apt-get install php5-curl`
## 安装方法
1. 如果您通过composer管理您的项目依赖,可以在你的项目根目录运行:
$ composer require aliyuncs/oss-sdk-php
或者在你的`composer.json`中声明对Aliyun OSS SDK for PHP的依赖:
"require": {
"aliyuncs/oss-sdk-php": "~2.0"
}
然后通过`composer install`安装依赖。composer安装完成后,在您的PHP代码中引入依赖即可:
require_once __DIR__ . '/vendor/autoload.php';
2. 您也可以直接下载已经打包好的[phar文件][releases-page],然后在你
的代码中引入这个文件即可:
require_once '/path/to/oss-sdk-php.phar';
3. 下载SDK源码,在您的代码中引入SDK目录下的`autoload.php`文件:
require_once '/path/to/oss-sdk/autoload.php';
## 快速使用
### 常用类
| 类名 | 解释 |
|:------------------|:------------------------------------|
|OSS\OssClient | OSS客户端类,用户通过OssClient的实例调用接口 |
|OSS\Core\OssException | OSS异常类,用户在使用的过程中,只需要注意这个异常|
### OssClient初始化
SDK的OSS操作通过OssClient类完成的,下面代码创建一个OssClient对象:
```php
<?php
$accessKeyId = "<您从OSS获得的AccessKeyId>"; ;
$accessKeySecret = "<您从OSS获得的AccessKeySecret>";
$endpoint = "<您选定的OSS数据中心访问域名,例如oss-cn-hangzhou.aliyuncs.com>";
try {
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
} catch (OssException $e) {
print $e->getMessage();
}
```
### 文件操作
文件(又称对象,Object)是OSS中最基本的数据单元,您可以把它简单地理解为文件,用下面代码可以实现一个Object的上传:
```php
<?php
$bucket = "<您使用的Bucket名字,注意命名规范>";
$object = "<您使用的Object名字,注意命名规范>";
$content = "Hello, OSS!"; // 上传的文件内容
try {
$ossClient->putObject($bucket, $object, $content);
} catch (OssException $e) {
print $e->getMessage();
}
```
### 存储空间操作
存储空间(又称Bucket)是一个用户用来管理所存储Object的存储空间,对于用户来说是一个管理Object的单元,所有的Object都必须隶属于某个Bucket。您可以按照下面的代码新建一个Bucket:
```php
<?php
$bucket = "<您使用的Bucket名字,注意命名规范>";
try {
$ossClient->createBucket($bucket);
} catch (OssException $e) {
print $e->getMessage();
}
```
### 返回结果处理
OssClient提供的接口返回返回数据分为两种:
* Put,Delete类接口,接口返回null,如果没有OssException,即可认为操作成功
* Get,List类接口,接口返回对应的数据,如果没有OssException,即可认为操作成功,举个例子:
```php
<?php
$bucketListInfo = $ossClient->listBuckets();
$bucketList = $bucketListInfo->getBucketList();
foreach($bucketList as $bucket) {
print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreatedate() . "\n");
}
```
上面代码中的$bucketListInfo的数据类型是 `OSS\Model\BucketListInfo`
### 运行Sample程序
1. 修改 `samples/Config.php`, 补充配置信息
2. 执行 `cd samples/ && php RunAll.php`
### 运行单元测试
1. 执行`composer install`下载依赖的库
2. 设置环境变量
export OSS_ACCESS_KEY_ID=access-key-id
export OSS_ACCESS_KEY_SECRET=access-key-secret
export OSS_ENDPOINT=endpoint
export OSS_BUCKET=bucket-name
3. 执行 `php vendor/bin/phpunit`
## License
- MIT
## 联系我们
- [阿里云OSS官方网站](http://oss.aliyun.com)
- [阿里云OSS官方论坛](http://bbs.aliyun.com)
- [阿里云OSS官方文档中心](http://www.aliyun.com/product/oss#Docs)
- 阿里云官方技术支持:[提交工单](https://workorder.console.aliyun.com/#/ticket/createIndex)
[releases-page]: https://github.com/aliyun/aliyun-oss-php-sdk/releases
[phar-composer]: https://github.com/clue/phar-composer
# Alibaba Cloud OSS SDK for PHP
[![Latest Stable Version](https://poser.pugx.org/aliyuncs/oss-sdk-php/v/stable)](https://packagist.org/packages/aliyuncs/oss-sdk-php)
[![Build Status](https://travis-ci.org/aliyun/aliyun-oss-php-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-php-sdk)
[![Coverage Status](https://coveralls.io/repos/github/aliyun/aliyun-oss-php-sdk/badge.svg?branch=master)](https://coveralls.io/github/aliyun/aliyun-oss-php-sdk?branch=master)
## [README of Chinese](https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/README-CN.md)
## Overview
Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring a massive capacity, security, a low cost, and high reliability. You can upload and download data on any application anytime and anywhere by calling APIs, and perform simple management of data through the web console. The OSS can store any type of files and therefore applies to various websites, development enterprises and developers.
## Run environment
- PHP 5.3+.
- cURL extension.
Tips:
- In Ubuntu, you can use the ***apt-get*** package manager to install the *PHP cURL extension*: `sudo apt-get install php5-curl`.
## Install OSS PHP SDK
- If you use the ***composer*** to manage project dependencies, run the following command in your project's root directory:
composer require aliyuncs/oss-sdk-php
You can also declare the dependency on Alibaba Cloud OSS SDK for PHP in the `composer.json` file.
"require": {
"aliyuncs/oss-sdk-php": "~2.0"
}
Then run `composer install` to install the dependency. After the Composer Dependency Manager is installed, import the dependency in your PHP code:
require_once __DIR__ . '/vendor/autoload.php';
- You can also directly download the packaged [PHAR File][releases-page], and
introduce the file to your code:
require_once '/path/to/oss-sdk-php.phar';
- Download the SDK source code, and introduce the `autoload.php` file under the SDK directory to your code:
require_once '/path/to/oss-sdk/autoload.php';
## Quick use
### Common classes
| Class | Explanation |
|:------------------|:------------------------------------|
|OSS\OSSClient | OSS client class. An OSSClient instance can be used to call the interface. |
|OSS\Core\OSSException |OSS Exception class . You only need to pay attention to this exception when you use the OSSClient. |
### Initialize an OSSClient
The SDK's operations for the OSS are performed through the OSSClient class. The code below creates an OSSClient object:
```php
<?php
$accessKeyId = "<AccessKeyID that you obtain from OSS>";
$accessKeySecret = "<AccessKeySecret that you obtain from OSS>";
$endpoint = "<Domain that you select to access an OSS data center, such as "oss-cn-hangzhou.aliyuncs.com>";
try {
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
} catch (OssException $e) {
print $e->getMessage();
}
```
### Operations on objects
Objects are the most basic data units on the OSS. You can simply consider objects as files. The following code uploads an object:
```php
<?php
$bucket= "<Name of the bucket in use. Pay attention to naming conventions>";
$object = "<Name of the object in use. Pay attention to naming conventions>";
$content = "Hello, OSS!"; // Content of the uploaded file
try {
$ossClient->putObject($bucket, $object, $content);
} catch (OssException $e) {
print $e->getMessage();
}
```
### Operations on buckets
Buckets are the space that you use to manage the stored objects. It is an object management unit for users. Each object must belong to a bucket. You can create a bucket with the following code:
```php
<?php
$bucket= "<Name of the bucket in use. Pay attention to naming conventions>";
try {
$ossClient->createBucket($bucket);
} catch (OssException $e) {
print $e->getMessage();
}
```
### Handle returned results
The OSSClient provides the following two types of returned data from interfaces:
- Put and Delete interfaces: The *PUT* and *DELETE* operations are deemed successful if *null* is returned by the interfaces without *OSSException*.
- Get and List interfaces: The *GET* and *LIST* operations are deemed successful if the desired data is returned by the interfaces without *OSSException*. For example,
```php
<?php
$bucketListInfo = $ossClient->listBuckets();
$bucketList = $bucketListInfo->getBucketList();
foreach($bucketList as $bucket) {
print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreatedate() . "\n");
}
```
In the above code, $bucketListInfo falls into the 'OSS\Model\BucketListInfo' data type.
### Run a sample project
- Modify `samples/Config.php` to complete the configuration information.
- Run `cd samples/ && php RunAll.php`.
### Run a unit test
- Run `composer install` to download the dependent libraries.
- Set the environment variable.
export OSS_ACCESS_KEY_ID=access-key-id
export OSS_ACCESS_KEY_SECRET=access-key-secret
export OSS_ENDPOINT=endpoint
export OSS_BUCKET=bucket-name
- Run `php vendor/bin/phpunit`
## License
- MIT
## Contact us
- [Alibaba Cloud OSS official website](http://oss.aliyun.com).
- [Alibaba Cloud OSS official forum](http://bbs.aliyun.com).
- [Alibaba Cloud OSS official documentation center](http://www.aliyun.com/product/oss#Docs).
- Alibaba Cloud official technical support: [Submit a ticket](https://workorder.console.aliyun.com/#/ticket/createIndex).
[releases-page]: https://github.com/aliyun/aliyun-oss-php-sdk/releases
[phar-composer]: https://github.com/clue/phar-composer
<?php
function classLoader($class)
{
$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$file = __DIR__ . DIRECTORY_SEPARATOR .'src'. DIRECTORY_SEPARATOR . $path . '.php';
if (file_exists($file)) {
require_once $file;
}
}
spl_autoload_register('classLoader');
\ No newline at end of file
#! /usr/bin/env bash
# Remove dev deps to reduce phar size
rm -rf composer.lock vendor/
# Generate composer.lock
composer install --no-dev
# Find SDK version
version=$(grep 'const OSS_VERSION' src/OSS/OssClient.php | grep -oE '[0-9.]+')
# Build phar
phar-composer build . aliyun-oss-php-sdk-$version.phar
{
"name": "aliyuncs/oss-sdk-php",
"description": "Aliyun OSS SDK for PHP",
"homepage": "http://www.aliyun.com/product/oss/",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Aliyuncs",
"homepage": "http://www.aliyun.com"
}
],
"require": {
"php":">=5.3"
},
"require-dev" : {
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "~1.0"
},
"minimum-stability": "stable",
"autoload": {
"psr-4": {"OSS\\": "src/OSS"}
}
}
<?php
require_once __DIR__ . '/vendor/autoload.php';
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<phpunit>
<filter>
<whitelist>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="coverage.xml" />
</logging>
<testsuites>
<testsuite name="FunctionTest">
<directory>./tests</directory>
<exclude>./tests/OSS/Tests/BucketCnameTest.php</exclude>
</testsuite>
</testsuites>
</phpunit>
<?php
require_once __DIR__ . '/Common.php';
use OSS\OssClient;
use OSS\Core\OssException;
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
$bucket = Common::getBucketName();
//******************************* 简单使用 ****************************************************************
//创建bucket
$ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
Common::println("bucket $bucket created");
// 判断Bucket是否存在
$doesExist = $ossClient->doesBucketExist($bucket);
Common::println("bucket $bucket exist? " . ($doesExist ? "yes" : "no"));
// 获取Bucket列表
$bucketListInfo = $ossClient->listBuckets();
// 设置bucket的ACL
$ossClient->putBucketAcl($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
Common::println("bucket $bucket acl put");
// 获取bucket的ACL
$acl = $ossClient->getBucketAcl($bucket);
Common::println("bucket $bucket acl get: " . $acl);
//******************************* 完整用法参考下面函数 ****************************************************
createBucket($ossClient, $bucket);
doesBucketExist($ossClient, $bucket);
deleteBucket($ossClient, $bucket);
putBucketAcl($ossClient, $bucket);
getBucketAcl($ossClient, $bucket);
listBuckets($ossClient);
/**
* 创建一个存储空间
* acl 指的是bucket的访问控制权限,有三种,私有读写,公共读私有写,公共读写。
* 私有读写就是只有bucket的拥有者或授权用户才有权限操作
* 三种权限分别对应 (OssClient::OSS_ACL_TYPE_PRIVATE,OssClient::OSS_ACL_TYPE_PUBLIC_READ, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE)
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 要创建的存储空间名称
* @return null
*/
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");
}
/**
* 判断Bucket是否存在
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
*/
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");
}
}
/**
* 删除bucket,如果bucket不为空则bucket无法删除成功, 不为空表示bucket既没有object,也没有未完成的multipart上传时的parts
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 待删除的存储空间名称
* @return null
*/
function deleteBucket($ossClient, $bucket)
{
try {
$ossClient->deleteBucket($bucket);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
/**
* 设置bucket的acl配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
function putBucketAcl($ossClient, $bucket)
{
$acl = OssClient::OSS_ACL_TYPE_PRIVATE;
try {
$ossClient->putBucketAcl($bucket, $acl);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
/**
* 获取bucket的acl配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
function getBucketAcl($ossClient, $bucket)
{
try {
$res = $ossClient->getBucketAcl($bucket);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
print('acl: ' . $res);
}
/**
* 列出用户所有的Bucket
*
* @param OssClient $ossClient OssClient实例
* @return null
*/
function listBuckets($ossClient)
{
$bucketList = null;
try {
$bucketListInfo = $ossClient->listBuckets();
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
$bucketList = $bucketListInfo->getBucketList();
foreach ($bucketList as $bucket) {
print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreatedate() . "\n");
}
}
<?php
require_once __DIR__ . '/Common.php';
use OSS\OssClient;
use OSS\Core\OssException;
use OSS\Model\CorsConfig;
use OSS\Model\CorsRule;
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
$bucket = Common::getBucketName();
//******************************* 简单使用 ****************************************************************
// 设置cors配置
$corsConfig = new CorsConfig();
$rule = new CorsRule();
$rule->addAllowedHeader("x-oss-header");
$rule->addAllowedOrigin("http://www.b.com");
$rule->addAllowedMethod("POST");
$rule->setMaxAgeSeconds(10);
$corsConfig->addRule($rule);
$ossClient->putBucketCors($bucket, $corsConfig);
Common::println("bucket $bucket corsConfig created:" . $corsConfig->serializeToXml());
// 获取cors配置
$corsConfig = $ossClient->getBucketCors($bucket);
Common::println("bucket $bucket corsConfig fetched:" . $corsConfig->serializeToXml());
// 删除cors配置
$ossClient->deleteBucketCors($bucket);
Common::println("bucket $bucket corsConfig deleted");
//******************************* 完整用法参考下面函数 *****************************************************
putBucketCors($ossClient, $bucket);
getBucketCors($ossClient, $bucket);
deleteBucketCors($ossClient, $bucket);
getBucketCors($ossClient, $bucket);
/**
* 设置bucket的cors配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
function putBucketCors($ossClient, $bucket)
{
$corsConfig = new CorsConfig();
$rule = new CorsRule();
$rule->addAllowedHeader("x-oss-header");
$rule->addAllowedOrigin("http://www.b.com");
$rule->addAllowedMethod("POST");
$rule->setMaxAgeSeconds(10);
$corsConfig->addRule($rule);
try {
$ossClient->putBucketCors($bucket, $corsConfig);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
/**
* 获取并打印bucket的cors配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
function getBucketCors($ossClient, $bucket)
{
$corsConfig = null;
try {
$corsConfig = $ossClient->getBucketCors($bucket);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
print($corsConfig->serializeToXml() . "\n");
}
/**
* 删除bucket的所有的cors配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
function deleteBucketCors($ossClient, $bucket)
{
try {
$ossClient->deleteBucketCors($bucket);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
<?php
require_once __DIR__ . '/Common.php';
use OSS\OssClient;
use OSS\Core\OssException;
use OSS\Model\LifecycleAction;
use OSS\Model\LifecycleConfig;
use OSS\Model\LifecycleRule;
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//******************************* 简单使用 *******************************************************
//设置lifecycle规则
$lifecycleConfig = new LifecycleConfig();
$actions = array();
$actions[] = new LifecycleAction("Expiration", "Days", 3);
$lifecycleRule = new LifecycleRule("delete obsoleted files", "obsoleted/", "Enabled", $actions);
$lifecycleConfig->addRule($lifecycleRule);
$ossClient->putBucketLifecycle($bucket, $lifecycleConfig);
Common::println("bucket $bucket lifecycleConfig created:" . $lifecycleConfig->serializeToXml());
//获取lifecycle规则
$lifecycleConfig = $ossClient->getBucketLifecycle($bucket);
Common::println("bucket $bucket lifecycleConfig fetched:" . $lifecycleConfig->serializeToXml());
//删除bucket的lifecycle配置
$ossClient->deleteBucketLifecycle($bucket);
Common::println("bucket $bucket lifecycleConfig deleted");
//***************************** 完整用法参考下面函数 ***********************************************
putBucketLifecycle($ossClient, $bucket);
getBucketLifecycle($ossClient, $bucket);
deleteBucketLifecycle($ossClient, $bucket);
getBucketLifecycle($ossClient, $bucket);
/**
* 设置bucket的生命周期配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
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");
}
/**
* 获取bucket的生命周期配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
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");
}
/**
* 删除bucket的生命周期配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
function deleteBucketLifecycle($ossClient, $bucket)
{
try {
$ossClient->deleteBucketLifecycle($bucket);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
<?php
require_once __DIR__ . '/Common.php';
use OSS\OssClient;
use OSS\Core\OssException;
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//*******************************简单使用***************************************************************
// 设置Bucket访问日志记录规则, 访问日志文件的存放位置是同bucket下的access.log前缀的文件
$ossClient->putBucketLogging($bucket, $bucket, "access.log", array());
Common::println("bucket $bucket lifecycleConfig created");
// 获取Bucket访问日志记录规则
$loggingConfig = $ossClient->getBucketLogging($bucket, array());
Common::println("bucket $bucket lifecycleConfig fetched:" . $loggingConfig->serializeToXml());
// 删除Bucket访问日志记录规则
$loggingConfig = $ossClient->getBucketLogging($bucket, array());
Common::println("bucket $bucket lifecycleConfig deleted");
//******************************* 完整用法参考下面函数 ****************************************************
putBucketLogging($ossClient, $bucket);
getBucketLogging($ossClient, $bucket);
deleteBucketLogging($ossClient, $bucket);
getBucketLogging($ossClient, $bucket);
/**
* 设置bucket的Logging配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
function putBucketLogging($ossClient, $bucket)
{
$option = array();
//访问日志存放在本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");
}
/**
* 获取bucket的Logging配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
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");
}
/**
* 删除bucket的Logging配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
function deleteBucketLogging($ossClient, $bucket)
{
try {
$ossClient->deleteBucketLogging($bucket);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
<?php
require_once __DIR__ . '/Common.php';
use OSS\OssClient;
use OSS\Core\OssException;
use \OSS\Model\RefererConfig;
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//******************************* 简单使用 ****************************************************************
//设置referer白名单
$refererConfig = new RefererConfig();
$refererConfig->setAllowEmptyReferer(true);
$refererConfig->addReferer("www.aliiyun.com");
$refererConfig->addReferer("www.aliiyuncs.com");
$ossClient->putBucketReferer($bucket, $refererConfig);
Common::println("bucket $bucket refererConfig created:" . $refererConfig->serializeToXml());
//获取Referer白名单
$refererConfig = $ossClient->getBucketReferer($bucket);
Common::println("bucket $bucket refererConfig fetched:" . $refererConfig->serializeToXml());
//删除referer白名单
$refererConfig = new RefererConfig();
$ossClient->putBucketReferer($bucket, $refererConfig);
Common::println("bucket $bucket refererConfig deleted");
//******************************* 完整用法参考下面函数 ****************************************************
putBucketReferer($ossClient, $bucket);
getBucketReferer($ossClient, $bucket);
deleteBucketReferer($ossClient, $bucket);
getBucketReferer($ossClient, $bucket);
/**
* 设置bucket的防盗链配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
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");
}
/**
* 获取bucket的防盗链配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
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");
}
/**
* 删除bucket的防盗链配置
* Referer白名单不能直接清空,只能通过重新设置来覆盖之前的规则。
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
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");
}
<?php
require_once __DIR__ . '/Common.php';
use OSS\OssClient;
use OSS\Core\OssException;
use OSS\Model\WebsiteConfig;
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//*******************************简单使用***************************************************************
// 设置Bucket的静态网站托管模式
$websiteConfig = new WebsiteConfig("index.html", "error.html");
$ossClient->putBucketWebsite($bucket, $websiteConfig);
Common::println("bucket $bucket websiteConfig created:" . $websiteConfig->serializeToXml());
// 查看Bucket的静态网站托管状态
$websiteConfig = $ossClient->getBucketWebsite($bucket);
Common::println("bucket $bucket websiteConfig fetched:" . $websiteConfig->serializeToXml());
// 删除Bucket的静态网站托管模式
$ossClient->deleteBucketWebsite($bucket);
Common::println("bucket $bucket websiteConfig deleted");
//******************************* 完整用法参考下面函数 ****************************************************
putBucketWebsite($ossClient, $bucket);
getBucketWebsite($ossClient, $bucket);
deleteBucketWebsite($ossClient, $bucket);
getBucketWebsite($ossClient, $bucket);
/**
* 设置bucket的静态网站托管模式配置
*
* @param $ossClient OssClient
* @param $bucket string 存储空间名称
* @return null
*/
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");
}
/**
* 获取bucket的静态网站托管状态
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
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");
}
/**
* 删除bucket的静态网站托管模式配置
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
function deleteBucketWebsite($ossClient, $bucket)
{
try {
$ossClient->deleteBucketWebsite($bucket);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
<?php
require_once __DIR__ . '/Common.php';
use OSS\OssClient;
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//*******************************简单使用***************************************************************
/** putObject 使用callback上传内容到oss文件
* callbackurl参数指定请求回调的服务器url
* callbackbodytype参数可为application/json或application/x-www-form-urlencoded, 可选参数,默认为application/x-www-form-urlencoded
* OSS_CALLBACK_VAR参数可以不设置
*/
$url =
'{
"callbackUrl":"callback.oss-demo.com:23450",
"callbackHost":"oss-cn-hangzhou.aliyuncs.com",
"callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}&my_var1=${x:var1}&my_var2=${x:var2}",
"callbackBodyType":"application/x-www-form-urlencoded"
}';
$var =
'{
"x:var1":"value1",
"x:var2":"值2"
}';
$options = array(OssClient::OSS_CALLBACK => $url,
OssClient::OSS_CALLBACK_VAR => $var
);
$result = $ossClient->putObject($bucket, "b.file", "random content", $options);
Common::println($result['body']);
Common::println($result['info']['http_code']);
/**
* completeMultipartUpload 使用callback上传内容到oss文件
* callbackurl参数指定请求回调的服务器url
* callbackbodytype参数可为application/json或application/x-www-form-urlencoded, 可选参数,默认为application/x-www-form-urlencoded
* OSS_CALLBACK_VAR参数可以不设置
*/
$object = "multipart-callback-test.txt";
$copiedObject = "multipart-callback-test.txt.copied";
$ossClient->putObject($bucket, $copiedObject, file_get_contents(__FILE__));
/**
* step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id
*/
$upload_id = $ossClient->initiateMultipartUpload($bucket, $object);
/**
* step 2. uploadPartCopy
*/
$copyId = 1;
$eTag = $ossClient->uploadPartCopy($bucket, $copiedObject, $bucket, $object, $copyId, $upload_id);
$upload_parts[] = array(
'PartNumber' => $copyId,
'ETag' => $eTag,
);
$listPartsInfo = $ossClient->listParts($bucket, $object, $upload_id);
/**
* step 3.
*/
$json =
'{
"callbackUrl":"callback.oss-demo.com:23450",
"callbackHost":"oss-cn-hangzhou.aliyuncs.com",
"callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}",
"callbackBodyType":"application/json"
}';
$var =
'{
"x:var1":"value1",
"x:var2":"值2"
}';
$options = array(OssClient::OSS_CALLBACK => $json,
OssClient::OSS_CALLBACK_VAR => $var);
$result = $ossClient->completeMultipartUpload($bucket, $object, $upload_id, $upload_parts, $options);
Common::println($result['body']);
Common::println($result['info']['http_code']);
<?php
if (is_file(__DIR__ . '/../autoload.php')) {
require_once __DIR__ . '/../autoload.php';
}
if (is_file(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
}
require_once __DIR__ . '/Config.php';
use OSS\OssClient;
use OSS\Core\OssException;
/**
* Class Common
*
* 示例程序【Samples/*.php】 的Common类,用于获取OssClient实例和其他公用方法
*/
class Common
{
const endpoint = Config::OSS_ENDPOINT;
const accessKeyId = Config::OSS_ACCESS_ID;
const accessKeySecret = Config::OSS_ACCESS_KEY;
const bucket = Config::OSS_TEST_BUCKET;
/**
* 根据Config配置,得到一个OssClient实例
*
* @return OssClient 一个OssClient实例
*/
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;
}
public static function getBucketName()
{
return self::bucket;
}
/**
* 工具方法,创建一个存储空间,如果发生异常直接exit
*/
public static function createBucket()
{
$ossClient = self::getOssClient();
if (is_null($ossClient)) exit(1);
$bucket = self::getBucketName();
$acl = OssClient::OSS_ACL_TYPE_PUBLIC_READ;
try {
$ossClient->createBucket($bucket, $acl);
} catch (OssException $e) {
$message = $e->getMessage();
if (\OSS\Core\OssUtil::startsWith($message, 'http status: 403')) {
echo "Please Check your AccessKeyId and AccessKeySecret" . "\n";
exit(0);
} elseif (strpos($message, "BucketAlreadyExists") !== false) {
echo "Bucket already exists. Please check whether the bucket belongs to you, or it was visited with correct endpoint. " . "\n";
exit(0);
}
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": OK" . "\n");
}
public static function println($message)
{
if (!empty($message)) {
echo strval($message) . "\n";
}
}
}
Common::createBucket();
<?php
/**
* Class Config
*
* 执行Sample示例所需要的配置,用户在这里配置好Endpoint,AccessId, AccessKey和Sample示例操作的
* bucket后,便可以直接运行RunAll.php, 运行所有的samples
*/
final class Config
{
const OSS_ACCESS_ID = '';
const OSS_ACCESS_KEY = '';
const OSS_ENDPOINT = '';
const OSS_TEST_BUCKET = '';
}
<?php
require_once __DIR__ . '/Common.php';
use OSS\OssClient;
$bucketName = Common::getBucketName();
$object = "example.jpg";
$ossClient = Common::getOssClient();
$download_file = "download.jpg";
if (is_null($ossClient)) exit(1);
//*******************************简单使用***************************************************************
// 先把本地的example.jpg上传到指定$bucket, 命名为$object
$ossClient->uploadFile($bucketName, $object, "example.jpg");
// 图片缩放
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/resize,m_fixed,h_100,w_100", );
$ossClient->getObject($bucketName, $object, $options);
printImage("imageResize",$download_file);
// 图片裁剪
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/crop,w_100,h_100,x_100,y_100,r_1", );
$ossClient->getObject($bucketName, $object, $options);
printImage("iamgeCrop", $download_file);
// 图片旋转
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/rotate,90", );
$ossClient->getObject($bucketName, $object, $options);
printImage("imageRotate", $download_file);
// 图片锐化
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/sharpen,100", );
$ossClient->getObject($bucketName, $object, $options);
printImage("imageSharpen", $download_file);
// 图片水印
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ", );
$ossClient->getObject($bucketName, $object, $options);
printImage("imageWatermark", $download_file);
// 图片格式转换
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/format,png", );
$ossClient->getObject($bucketName, $object, $options);
printImage("imageFormat", $download_file);
// 获取图片信息
$options = array(
OssClient::OSS_FILE_DOWNLOAD => $download_file,
OssClient::OSS_PROCESS => "image/info", );
$ossClient->getObject($bucketName, $object, $options);
printImage("imageInfo", $download_file);
/**
* 生成一个带签名的可用于浏览器直接打开的url, URL的有效期是3600秒
*/
$timeout = 3600;
$options = array(
OssClient::OSS_PROCESS => "image/resize,m_lfit,h_100,w_100",
);
$signedUrl = $ossClient->signUrl($bucketName, $object, $timeout, "GET", $options);
Common::println("rtmp url: \n" . $signedUrl);
//最后删除上传的$object
$ossClient->deleteObject($bucketName, $object);
function printImage($func, $imageFile)
{
$array = getimagesize($imageFile);
Common::println("$func, image width: " . $array[0]);
Common::println("$func, image height: " . $array[1]);
Common::println("$func, image type: " . ($array[2] === 2 ? 'jpg' : 'png'));
Common::println("$func, image size: " . ceil(filesize($imageFile)));
}
<?php
require_once __DIR__ . '/Common.php';
use OSS\OssClient;
use OSS\Model\LiveChannelConfig;
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//******************************* 简单使用 *******************************************************
/**
创建一个直播频道
频道的名称是test_rtmp_live。直播生成的m3u8文件叫做test.m3u8,该索引文件包含3片ts文件,每片ts文件的时长为5秒(这只是一个建议值,具体的时长取决于关键帧)。
*/
$config = new LiveChannelConfig(array(
'description' => 'live channel test',
'type' => 'HLS',
'fragDuration' => 10,
'fragCount' => 5,
'playListName' => 'hello.m3u8'
));
$info = $ossClient->putBucketLiveChannel($bucket, 'test_rtmp_live', $config);
Common::println("bucket $bucket liveChannel created:\n" .
"live channel name: ". $info->getName() . "\n" .
"live channel description: ". $info->getDescription() . "\n" .
"publishurls: ". $info->getPublishUrls()[0] . "\n" .
"playurls: ". $info->getPlayUrls()[0] . "\n");
/**
对创建好的频道,可以使用listBucketLiveChannels来进行列举已达到管理的目的。
prefix可以按照前缀过滤list出来的频道。
max_keys表示迭代器内部一次list出来的频道的最大数量,这个值最大不能超过1000,不填写的话默认为100。
*/
$list = $ossClient->listBucketLiveChannels($bucket);
Common::println("bucket $bucket listLiveChannel:\n" .
"list live channel prefix: ". $list->getPrefix() . "\n" .
"list live channel marker: ". $list->getMarker() . "\n" .
"list live channel maxkey: ". $list->getMaxKeys() . "\n" .
"list live channel IsTruncated: ". $list->getIsTruncated() . "\n" .
"list live channel getNextMarker: ". $list->getNextMarker() . "\n");
foreach($list->getChannelList() as $list)
{
Common::println("bucket $bucket listLiveChannel:\n" .
"list live channel IsTruncated: ". $list->getName() . "\n" .
"list live channel Description: ". $list->getDescription() . "\n" .
"list live channel Status: ". $list->getStatus() . "\n" .
"list live channel getNextMarker: ". $list->getLastModified() . "\n");
}
/**
创建直播频道之后拿到推流用的play_url(rtmp推流的url,如果Bucket不是公共读写权限那么还需要带上签名,见下文示例)和推流用的publish_url(推流产生的m3u8文件的url)
*/
$play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600, array('params' => array('playlistName' => 'playlist.m3u8')));
Common::println("bucket $bucket rtmp url: \n" . $play_url);
$play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600);
Common::println("bucket $bucket rtmp url: \n" . $play_url);
/**
创建好直播频道,如果想把这个频道禁用掉(断掉正在推的流或者不再允许向一个地址推流),应该使用putLiveChannelStatus接口,将频道的status改成“Disabled”,如果要将一个禁用状态的频道启用,那么也是调用这个接口,将status改成“Enabled”
*/
$resp = $ossClient->putLiveChannelStatus($bucket, "test_rtmp_live", "enabled");
/**
创建好直播频道之后调用getLiveChannelInfo可以得到频道相关的信息
*/
$info = $ossClient->getLiveChannelInfo($bucket, 'test_rtmp_live');
Common::println("bucket $bucket LiveChannelInfo:\n" .
"live channel info description: ". $info->getDescription() . "\n" .
"live channel info status: ". $info->getStatus() . "\n" .
"live channel info type: ". $info->getType() . "\n" .
"live channel info fragDuration: ". $info->getFragDuration() . "\n" .
"live channel info fragCount: ". $info->getFragCount() . "\n" .
"live channel info playListName: ". $info->getPlayListName() . "\n");
/**
如果想查看一个频道历史推流记录,可以调用getLiveChannelHistory。目前最多可以看到10次推流的记录
*/
$history = $ossClient->getLiveChannelHistory($bucket, "test_rtmp_live");
if (count($history->getLiveRecordList()) != 0)
{
foreach($history->getLiveRecordList() as $recordList)
{
Common::println("bucket $bucket liveChannelHistory:\n" .
"live channel history startTime: ". $recordList->getStartTime() . "\n" .
"live channel history endTime: ". $recordList->getEndTime() . "\n" .
"live channel history remoteAddr: ". $recordList->getRemoteAddr() . "\n");
}
}
/**
对于正在推流的频道调用get_live_channel_stat可以获得流的状态信息。
如果频道正在推流,那么stat_result中的所有字段都有意义。
如果频道闲置或者处于“Disabled”状态,那么status为“Idle”或“Disabled”,其他字段无意义。
*/
$status = $ossClient->getLiveChannelStatus($bucket, "test_rtmp_live");
Common::println("bucket $bucket listLiveChannel:\n" .
"live channel status status: ". $status->getStatus() . "\n" .
"live channel status ConnectedTime: ". $status->getConnectedTime() . "\n" .
"live channel status VideoWidth: ". $status->getVideoWidth() . "\n" .
"live channel status VideoHeight: ". $status->getVideoHeight() . "\n" .
"live channel status VideoFrameRate: ". $status->getVideoFrameRate() . "\n" .
"live channel status VideoBandwidth: ". $status->getVideoBandwidth() . "\n" .
"live channel status VideoCodec: ". $status->getVideoCodec() . "\n" .
"live channel status AudioBandwidth: ". $status->getAudioBandwidth() . "\n" .
"live channel status AudioSampleRate: ". $status->getAudioSampleRate() . "\n" .
"live channel status AdioCodec: ". $status->getAudioCodec() . "\n");
/**
* 如果希望利用直播推流产生的ts文件生成一个点播列表,可以使用postVodPlaylist方法。
* 指定起始时间为当前时间减去60秒,结束时间为当前时间,这意味着将生成一个长度为60秒的点播视频。
* 播放列表指定为“vod_playlist.m3u8”,也就是说这个接口调用成功之后会在OSS上生成一个名叫“vod_playlist.m3u8”的播放列表文件。
*/
$current_time = time();
$ossClient->postVodPlaylist($bucket,
"test_rtmp_live", "vod_playlist.m3u8",
array('StartTime' => $current_time - 60,
'EndTime' => $current_time)
);
/**
* 如果一个直播频道已经不打算再使用了,那么可以调用delete_live_channel来删除频道。
*/
$ossClient->deleteBucketLiveChannel($bucket, "test_rtmp_live");
<?php
require_once __DIR__ . '/Common.php';
use OSS\OssClient;
use OSS\Core\OssUtil;
use OSS\Core\OssException;
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//*******************************简单使用***************************************************************
/**
* 查看完整用法中的 "putObjectByRawApis"函数,查看使用基础的分片上传api进行文件上传,用户可以基于这个自行实现断点续传等功能
*/
// 使用分片上传接口上传文件, 接口会根据文件大小决定是使用普通上传还是分片上传
$ossClient->multiuploadFile($bucket, "file.php", __FILE__, array());
Common::println("local file " . __FILE__ . " is uploaded to the bucket $bucket, file.php");
// 上传本地目录到bucket内的targetdir子目录中
$ossClient->uploadDir($bucket, "targetdir", __DIR__);
Common::println("local dir " . __DIR__ . " is uploaded to the bucket $bucket, targetdir/");
// 列出当前未完成的分片上传
$listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, array());
//******************************* 完整用法参考下面函数 ****************************************************
multiuploadFile($ossClient, $bucket);
putObjectByRawApis($ossClient, $bucket);
uploadDir($ossClient, $bucket);
listMultipartUploads($ossClient, $bucket);
/**
* 通过multipart上传文件
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
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");
}
/**
* 使用基本的api分阶段进行分片上传
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @throws OssException
*/
function putObjectByRawApis($ossClient, $bucket)
{
$object = "test/multipart-test.txt";
/**
* step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id
*/
try {
$uploadId = $ossClient->initiateMultipartUpload($bucket, $object);
} catch (OssException $e) {
printf(__FUNCTION__ . ": initiateMultipartUpload FAILED\n");
printf($e->getMessage() . "\n");
return;
}
print(__FUNCTION__ . ": initiateMultipartUpload OK" . "\n");
/*
* step 2. 上传分片
*/
$partSize = 10 * 1024 * 1024;
$uploadFile = __FILE__;
$uploadFileSize = filesize($uploadFile);
$pieces = $ossClient->generateMultiuploadParts($uploadFileSize, $partSize);
$responseUploadPart = array();
$uploadPosition = 0;
$isCheckMd5 = true;
foreach ($pieces as $i => $piece) {
$fromPos = $uploadPosition + (integer)$piece[$ossClient::OSS_SEEK_TO];
$toPos = (integer)$piece[$ossClient::OSS_LENGTH] + $fromPos - 1;
$upOptions = array(
$ossClient::OSS_FILE_UPLOAD => $uploadFile,
$ossClient::OSS_PART_NUM => ($i + 1),
$ossClient::OSS_SEEK_TO => $fromPos,
$ossClient::OSS_LENGTH => $toPos - $fromPos + 1,
$ossClient::OSS_CHECK_MD5 => $isCheckMd5,
);
if ($isCheckMd5) {
$contentMd5 = OssUtil::getMd5SumForFile($uploadFile, $fromPos, $toPos);
$upOptions[$ossClient::OSS_CONTENT_MD5] = $contentMd5;
}
//2. 将每一分片上传到OSS
try {
$responseUploadPart[] = $ossClient->uploadPart($bucket, $object, $uploadId, $upOptions);
} catch (OssException $e) {
printf(__FUNCTION__ . ": initiateMultipartUpload, uploadPart - part#{$i} FAILED\n");
printf($e->getMessage() . "\n");
return;
}
printf(__FUNCTION__ . ": initiateMultipartUpload, uploadPart - part#{$i} OK\n");
}
$uploadParts = array();
foreach ($responseUploadPart as $i => $eTag) {
$uploadParts[] = array(
'PartNumber' => ($i + 1),
'ETag' => $eTag,
);
}
/**
* step 3. 完成上传
*/
try {
$ossClient->completeMultipartUpload($bucket, $object, $uploadId, $uploadParts);
} catch (OssException $e) {
printf(__FUNCTION__ . ": completeMultipartUpload FAILED\n");
printf($e->getMessage() . "\n");
return;
}
printf(__FUNCTION__ . ": completeMultipartUpload OK\n");
}
/**
* 按照目录上传文件
*
* @param OssClient $ossClient OssClient
* @param string $bucket 存储空间名称
*
*/
function uploadDir($ossClient, $bucket)
{
$localDirectory = ".";
$prefix = "samples/codes";
try {
$ossClient->uploadDir($bucket, $prefix, $localDirectory);
} catch (OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
printf(__FUNCTION__ . ": completeMultipartUpload OK\n");
}
/**
* 获取当前未完成的分片上传列表
*
* @param $ossClient OssClient
* @param $bucket string
*/
function listMultipartUploads($ossClient, $bucket)
{
$options = array(
'max-uploads' => 100,
'key-marker' => '',
'prefix' => '',
'upload-id-marker' => ''
);
try {
$listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, $options);
} catch (OssException $e) {
printf(__FUNCTION__ . ": listMultipartUploads FAILED\n");
printf($e->getMessage() . "\n");
return;
}
printf(__FUNCTION__ . ": listMultipartUploads OK\n");
$listUploadInfo = $listMultipartUploadInfo->getUploads();
var_dump($listUploadInfo);
}
This diff is collapsed.
<?php
error_reporting(E_ALL | E_NOTICE);
require_once __DIR__ . '/Bucket.php';
require_once __DIR__ . '/BucketCors.php';
require_once __DIR__ . '/BucketLifecycle.php';
require_once __DIR__ . '/BucketReferer.php';
require_once __DIR__ . '/BucketLogging.php';
require_once __DIR__ . '/BucketWebsite.php';
require_once __DIR__ . '/Signature.php';
require_once __DIR__ . '/Object.php';
require_once __DIR__ . '/MultipartUpload.php';
\ No newline at end of file
<?php
require_once __DIR__ . '/Common.php';
use OSS\Http\RequestCore;
use OSS\Http\ResponseCore;
use OSS\OssClient;
use OSS\Core\OssException;
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if (is_null($ossClient)) exit(1);
//******************************* 简单使用 ***************************************************************
$ossClient->uploadFile($bucket, "a.file", __FILE__);
// 生成GetObject的签名url,用户可以使用这个url直接在浏览器下载
$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600);
Common::println($signedUrl);
// 生成用于putObject的签名URL,用户可以直接用put方法使用这个url上传文件到 "a.file"
$signedUrl = $ossClient->signUrl($bucket, "a.file", "3600", "PUT");
Common::println($signedUrl);
// 生成从本地文件上传PutObject的签名url, 用户可以直接使用这个url把本地文件上传到 "a.file"
$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600, "PUT", array('Content-Type' => 'txt'));
Common::println($signedUrl);
//******************************* 完整用法参考下面函数 ****************************************************
getSignedUrlForPuttingObject($ossClient, $bucket);
getSignedUrlForPuttingObjectFromFile($ossClient, $bucket);
getSignedUrlForGettingObject($ossClient, $bucket);
/**
* 生成GetObject的签名url,主要用于私有权限下的读访问控制
*
* @param $ossClient OssClient OssClient实例
* @param $bucket string 存储空间名称
* @return null
*/
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");
/**
* 可以类似的代码来访问签名的URL,也可以输入到浏览器中去访问
*/
$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");
};
}
/**
* 生成PutObject的签名url,主要用于私有权限下的写访问控制
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
* @throws OssException
*/
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");
};
}
/**
* 生成PutObject的签名url,主要用于私有权限下的写访问控制, 用户可以利用生成的signedUrl
* 从文件上传文件
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @throws OssException
*/
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(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");
};
}
\ No newline at end of file
This diff is collapsed.
<?php
namespace OSS\Core;
/**
* Class OssException
*
* OssClient在使用的时候,所抛出的异常,用户在使用OssClient的时候,要Try住相关代码,
* try的Exception应该是OssException,其中会得到相关异常原因
*
* @package OSS\Core
*/
class OssException extends \Exception
{
private $details = array();
function __construct($details)
{
if (is_array($details)) {
$message = $details['code'] . ': ' . $details['message']
. ' RequestId: ' . $details['request-id'];
parent::__construct($message);
$this->details = $details;
} else {
$message = $details;
parent::__construct($message);
}
}
public function getHTTPStatus()
{
return isset($this->details['status']) ? $this->details['status'] : '';
}
public function getRequestId()
{
return isset($this->details['request-id']) ? $this->details['request-id'] : '';
}
public function getErrorCode()
{
return isset($this->details['code']) ? $this->details['code'] : '';
}
public function getErrorMessage()
{
return isset($this->details['message']) ? $this->details['message'] : '';
}
public function getDetails()
{
return isset($this->details['body']) ? $this->details['body'] : '';
}
}
This diff is collapsed.
Copyright (c) 2006-2010 Ryan Parman, Foleeo Inc., and contributors. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
* Neither the name of Ryan Parman, Foleeo Inc. nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
This diff is collapsed.
<?php
namespace OSS\Http;
class RequestCore_Exception extends \Exception
{
}
\ No newline at end of file
<?php
namespace OSS\Http;
/**
* Container for all response-related methods.
*/
class ResponseCore
{
/**
* Stores the HTTP header information.
*/
public $header;
/**
* Stores the SimpleXML response.
*/
public $body;
/**
* Stores the HTTP response code.
*/
public $status;
/**
* Constructs a new instance of this class.
*
* @param array $header (Required) Associative array of HTTP headers (typically returned by <RequestCore::get_response_header()>).
* @param string $body (Required) XML-formatted response from AWS.
* @param integer $status (Optional) HTTP response status code from the request.
* @return Mixed Contains an <php:array> `header` property (HTTP headers as an associative array), a <php:SimpleXMLElement> or <php:string> `body` property, and an <php:integer> `status` code.
*/
public function __construct($header, $body, $status = null)
{
$this->header = $header;
$this->body = $body;
$this->status = $status;
return $this;
}
/**
* Did we receive the status code we expected?
*
* @param integer|array $codes (Optional) The status code(s) to expect. Pass an <php:integer> for a single acceptable value, or an <php:array> of integers for multiple acceptable values.
* @return boolean Whether we received the expected status code or not.
*/
public function isOK($codes = array(200, 201, 204, 206))
{
if (is_array($codes)) {
return in_array($this->status, $codes);
}
return $this->status === $codes;
}
}
\ No newline at end of file
<?php
namespace OSS\Model;
/**
* Bucket信息,ListBuckets接口返回数据
*
* Class BucketInfo
* @package OSS\Model
*/
class BucketInfo
{
/**
* BucketInfo constructor.
*
* @param string $location
* @param string $name
* @param string $createDate
*/
public function __construct($location, $name, $createDate)
{
$this->location = $location;
$this->name = $name;
$this->createDate = $createDate;
}
/**
* 得到bucket所在的region
*
* @return string
*/
public function getLocation()
{
return $this->location;
}
/**
* 得到bucket的名称
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* 得到bucket的创建时间
*
* @return string
*/
public function getCreateDate()
{
return $this->createDate;
}
/**
* bucket所在的region
*
* @var string
*/
private $location;
/**
* bucket的名称
*
* @var string
*/
private $name;
/**
* bucket的创建事件
*
* @var string
*/
private $createDate;
}
\ No newline at end of file
<?php
namespace OSS\Model;
/**
* Class BucketListInfo
*
* ListBuckets接口返回的数据类型
*
* @package OSS\Model
*/
class BucketListInfo
{
/**
* BucketListInfo constructor.
* @param array $bucketList
*/
public function __construct(array $bucketList)
{
$this->bucketList = $bucketList;
}
/**
* 得到BucketInfo列表
*
* @return BucketInfo[]
*/
public function getBucketList()
{
return $this->bucketList;
}
/**
* BucketInfo信息列表
*
* @var array
*/
private $bucketList = array();
}
\ No newline at end of file
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class CnameConfig
* @package OSS\Model
*
* TODO: fix link
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
*/
class CnameConfig implements XmlConfig
{
public function __construct()
{
$this->cnameList = array();
}
/**
* @return array
* @example
* array(2) {
* [0]=>
* array(3) {
* ["Domain"]=>
* string(11) "www.foo.com"
* ["Status"]=>
* string(7) "enabled"
* ["LastModified"]=>
* string(8) "20150101"
* }
* [1]=>
* array(3) {
* ["Domain"]=>
* string(7) "bar.com"
* ["Status"]=>
* string(8) "disabled"
* ["LastModified"]=>
* string(8) "20160101"
* }
* }
*/
public function getCnames()
{
return $this->cnameList;
}
public function addCname($cname)
{
if (count($this->cnameList) >= self::OSS_MAX_RULES) {
throw new OssException(
"num of cname in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES));
}
$this->cnameList[] = array('Domain' => $cname);
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (!isset($xml->Cname)) return;
foreach ($xml->Cname as $entry) {
$cname = array();
foreach ($entry as $key => $value) {
$cname[strval($key)] = strval($value);
}
$this->cnameList[] = $cname;
}
}
public function serializeToXml()
{
$strXml = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<BucketCnameConfiguration>
</BucketCnameConfiguration>
EOF;
$xml = new \SimpleXMLElement($strXml);
foreach ($this->cnameList as $cname) {
$node = $xml->addChild('Cname');
foreach ($cname as $key => $value) {
$node->addChild($key, $value);
}
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
const OSS_MAX_RULES = 10;
private $cnameList = array();
}
\ No newline at end of file
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class CorsConfig
* @package OSS\Model
*
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
*/
class CorsConfig implements XmlConfig
{
/**
* CorsConfig constructor.
*/
public function __construct()
{
$this->rules = array();
}
/**
* 得到CorsRule列表
*
* @return CorsRule[]
*/
public function getRules()
{
return $this->rules;
}
/**
* 添加一条CorsRule
*
* @param CorsRule $rule
* @throws OssException
*/
public function addRule($rule)
{
if (count($this->rules) >= self::OSS_MAX_RULES) {
throw new OssException("num of rules in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES));
}
$this->rules[] = $rule;
}
/**
* 从xml数据中解析出CorsConfig
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (!isset($xml->CORSRule)) return;
foreach ($xml->CORSRule as $rule) {
$corsRule = new CorsRule();
foreach ($rule as $key => $value) {
if ($key === self::OSS_CORS_ALLOWED_HEADER) {
$corsRule->addAllowedHeader(strval($value));
} elseif ($key === self::OSS_CORS_ALLOWED_METHOD) {
$corsRule->addAllowedMethod(strval($value));
} elseif ($key === self::OSS_CORS_ALLOWED_ORIGIN) {
$corsRule->addAllowedOrigin(strval($value));
} elseif ($key === self::OSS_CORS_EXPOSE_HEADER) {
$corsRule->addExposeHeader(strval($value));
} elseif ($key === self::OSS_CORS_MAX_AGE_SECONDS) {
$corsRule->setMaxAgeSeconds(strval($value));
}
}
$this->addRule($corsRule);
}
return;
}
/**
* 生成xml字符串
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><CORSConfiguration></CORSConfiguration>');
foreach ($this->rules as $rule) {
$xmlRule = $xml->addChild('CORSRule');
$rule->appendToXml($xmlRule);
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
const OSS_CORS_ALLOWED_ORIGIN = 'AllowedOrigin';
const OSS_CORS_ALLOWED_METHOD = 'AllowedMethod';
const OSS_CORS_ALLOWED_HEADER = 'AllowedHeader';
const OSS_CORS_EXPOSE_HEADER = 'ExposeHeader';
const OSS_CORS_MAX_AGE_SECONDS = 'MaxAgeSeconds';
const OSS_MAX_RULES = 10;
/**
* orsRule列表
*
* @var CorsRule[]
*/
private $rules = array();
}
\ No newline at end of file
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class CorsRule
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
*/
class CorsRule
{
/**
* Rule中增加一条allowedOrigin
*
* @param string $allowedOrigin
*/
public function addAllowedOrigin($allowedOrigin)
{
if (!empty($allowedOrigin)) {
$this->allowedOrigins[] = $allowedOrigin;
}
}
/**
* Rule中增加一条allowedMethod
*
* @param string $allowedMethod
*/
public function addAllowedMethod($allowedMethod)
{
if (!empty($allowedMethod)) {
$this->allowedMethods[] = $allowedMethod;
}
}
/**
* Rule中增加一条allowedHeader
*
* @param string $allowedHeader
*/
public function addAllowedHeader($allowedHeader)
{
if (!empty($allowedHeader)) {
$this->allowedHeaders[] = $allowedHeader;
}
}
/**
* Rule中增加一条exposeHeader
*
* @param string $exposeHeader
*/
public function addExposeHeader($exposeHeader)
{
if (!empty($exposeHeader)) {
$this->exposeHeaders[] = $exposeHeader;
}
}
/**
* @return int
*/
public function getMaxAgeSeconds()
{
return $this->maxAgeSeconds;
}
/**
* @param int $maxAgeSeconds
*/
public function setMaxAgeSeconds($maxAgeSeconds)
{
$this->maxAgeSeconds = $maxAgeSeconds;
}
/**
* 得到AllowedHeaders列表
*
* @return string[]
*/
public function getAllowedHeaders()
{
return $this->allowedHeaders;
}
/**
* 得到AllowedOrigins列表
*
* @return string[]
*/
public function getAllowedOrigins()
{
return $this->allowedOrigins;
}
/**
* 得到AllowedMethods列表
*
* @return string[]
*/
public function getAllowedMethods()
{
return $this->allowedMethods;
}
/**
* 得到ExposeHeaders列表
*
* @return string[]
*/
public function getExposeHeaders()
{
return $this->exposeHeaders;
}
/**
* 根据提供的xmlRule, 把this按照一定的规则插入到$xmlRule中
*
* @param \SimpleXMLElement $xmlRule
* @throws OssException
*/
public function appendToXml(&$xmlRule)
{
if (!isset($this->maxAgeSeconds)) {
throw new OssException("maxAgeSeconds is not set in the Rule");
}
foreach ($this->allowedOrigins as $allowedOrigin) {
$xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_ORIGIN, $allowedOrigin);
}
foreach ($this->allowedMethods as $allowedMethod) {
$xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_METHOD, $allowedMethod);
}
foreach ($this->allowedHeaders as $allowedHeader) {
$xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_HEADER, $allowedHeader);
}
foreach ($this->exposeHeaders as $exposeHeader) {
$xmlRule->addChild(CorsConfig::OSS_CORS_EXPOSE_HEADER, $exposeHeader);
}
$xmlRule->addChild(CorsConfig::OSS_CORS_MAX_AGE_SECONDS, strval($this->maxAgeSeconds));
}
private $allowedHeaders = array();
private $allowedOrigins = array();
private $allowedMethods = array();
private $exposeHeaders = array();
private $maxAgeSeconds = null;
}
\ No newline at end of file
<?php
namespace OSS\Model;
/**
* Class GetLiveChannelHistory
* @package OSS\Model
*/
class GetLiveChannelHistory implements XmlConfig
{
public function getLiveRecordList()
{
return $this->liveRecordList;
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (isset($xml->LiveRecord)) {
foreach ($xml->LiveRecord as $record) {
$liveRecord = new LiveChannelHistory();
$liveRecord->parseFromXmlNode($record);
$this->liveRecordList[] = $liveRecord;
}
}
}
public function serializeToXml()
{
throw new OssException("Not implemented.");
}
private $liveRecordList = array();
}
<?php
namespace OSS\Model;
/**
* Class GetLiveChannelInfo
* @package OSS\Model
*/
class GetLiveChannelInfo implements XmlConfig
{
public function getDescription()
{
return $this->description;
}
public function getStatus()
{
return $this->status;
}
public function getType()
{
return $this->type;
}
public function getFragDuration()
{
return $this->fragDuration;
}
public function getFragCount()
{
return $this->fragCount;
}
public function getPlayListName()
{
return $this->playlistName;
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
$this->description = strval($xml->Description);
$this->status = strval($xml->Status);
if (isset($xml->Target)) {
foreach ($xml->Target as $target) {
$this->type = strval($target->Type);
$this->fragDuration = strval($target->FragDuration);
$this->fragCount = strval($target->FragCount);
$this->playlistName = strval($target->PlaylistName);
}
}
}
public function serializeToXml()
{
throw new OssException("Not implemented.");
}
private $description;
private $status;
private $type;
private $fragDuration;
private $fragCount;
private $playlistName;
}
<?php
namespace OSS\Model;
/**
* Class GetLiveChannelStatus
* @package OSS\Model
*/
class GetLiveChannelStatus implements XmlConfig
{
public function getStatus()
{
return $this->status;
}
public function getConnectedTime()
{
return $this->connectedTime;
}
public function getRemoteAddr()
{
return $this->remoteAddr;
}
public function getVideoWidth()
{
return $this->videoWidth;
}
public function getVideoHeight()
{
return $this->videoHeight;
}
public function getVideoFrameRate()
{
return $this->videoFrameRate;
}
public function getVideoBandwidth()
{
return $this->videoBandwidth;
}
public function getVideoCodec()
{
return $this->videoCodec;
}
public function getAudioBandwidth()
{
return $this->audioBandwidth;
}
public function getAudioSampleRate()
{
return $this->audioSampleRate;
}
public function getAudioCodec()
{
return $this->audioCodec;
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
$this->status = strval($xml->Status);
$this->connectedTime = strval($xml->ConnectedTime);
$this->remoteAddr = strval($xml->RemoteAddr);
if (isset($xml->Video)) {
foreach ($xml->Video as $video) {
$this->videoWidth = intval($video->Width);
$this->videoHeight = intval($video->Height);
$this->videoFrameRate = intval($video->FrameRate);
$this->videoBandwidth = intval($video->Bandwidth);
$this->videoCodec = strval($video->Codec);
}
}
if (isset($xml->Video)) {
foreach ($xml->Audio as $audio) {
$this->audioBandwidth = intval($audio->Bandwidth);
$this->audioSampleRate = intval($audio->SampleRate);
$this->audioCodec = strval($audio->Codec);
}
}
}
public function serializeToXml()
{
throw new OssException("Not implemented.");
}
private $status;
private $connectedTime;
private $remoteAddr;
private $videoWidth;
private $videoHeight;
private $videoFrameRate;
private $videoBandwidth;
private $videoCodec;
private $audioBandwidth;
private $audioSampleRate;
private $audioCodec;
}
<?php
namespace OSS\Model;
/**
* Class LifecycleAction
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
*/
class LifecycleAction
{
/**
* LifecycleAction constructor.
* @param string $action
* @param string $timeSpec
* @param string $timeValue
*/
public function __construct($action, $timeSpec, $timeValue)
{
$this->action = $action;
$this->timeSpec = $timeSpec;
$this->timeValue = $timeValue;
}
/**
* @return LifecycleAction
*/
public function getAction()
{
return $this->action;
}
/**
* @param string $action
*/
public function setAction($action)
{
$this->action = $action;
}
/**
* @return string
*/
public function getTimeSpec()
{
return $this->timeSpec;
}
/**
* @param string $timeSpec
*/
public function setTimeSpec($timeSpec)
{
$this->timeSpec = $timeSpec;
}
/**
* @return string
*/
public function getTimeValue()
{
return $this->timeValue;
}
/**
* @param string $timeValue
*/
public function setTimeValue($timeValue)
{
$this->timeValue = $timeValue;
}
/**
* appendToXml 把actions插入到xml中
*
* @param \SimpleXMLElement $xmlRule
*/
public function appendToXml(&$xmlRule)
{
$xmlAction = $xmlRule->addChild($this->action);
$xmlAction->addChild($this->timeSpec, $this->timeValue);
}
private $action;
private $timeSpec;
private $timeValue;
}
\ No newline at end of file
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class BucketLifecycleConfig
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
*/
class LifecycleConfig implements XmlConfig
{
/**
* 从xml数据中解析出LifecycleConfig
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$this->rules = array();
$xml = simplexml_load_string($strXml);
if (!isset($xml->Rule)) return;
$this->rules = array();
foreach ($xml->Rule as $rule) {
$id = strval($rule->ID);
$prefix = strval($rule->Prefix);
$status = strval($rule->Status);
$actions = array();
foreach ($rule as $key => $value) {
if ($key === 'ID' || $key === 'Prefix' || $key === 'Status') continue;
$action = $key;
$timeSpec = null;
$timeValue = null;
foreach ($value as $timeSpecKey => $timeValueValue) {
$timeSpec = $timeSpecKey;
$timeValue = strval($timeValueValue);
}
$actions[] = new LifecycleAction($action, $timeSpec, $timeValue);
}
$this->rules[] = new LifecycleRule($id, $prefix, $status, $actions);
}
return;
}
/**
* 生成xml字符串
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><LifecycleConfiguration></LifecycleConfiguration>');
foreach ($this->rules as $rule) {
$xmlRule = $xml->addChild('Rule');
$rule->appendToXml($xmlRule);
}
return $xml->asXML();
}
/**
*
* 添加LifecycleRule
*
* @param LifecycleRule $lifecycleRule
* @throws OssException
*/
public function addRule($lifecycleRule)
{
if (!isset($lifecycleRule)) {
throw new OssException("lifecycleRule is null");
}
$this->rules[] = $lifecycleRule;
}
/**
* 将配置转换成字符串,便于用户查看
*
* @return string
*/
public function __toString()
{
return $this->serializeToXml();
}
/**
* 得到所有的生命周期规则
*
* @return LifecycleRule[]
*/
public function getRules()
{
return $this->rules;
}
/**
* @var LifecycleRule[]
*/
private $rules;
}
<?php
namespace OSS\Model;
/**
* Class LifecycleRule
* @package OSS\Model
*
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
*/
class LifecycleRule
{
/**
* 得到规则ID
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string $id 规则ID
*/
public function setId($id)
{
$this->id = $id;
}
/**
* 得到文件前缀
*
* @return string
*/
public function getPrefix()
{
return $this->prefix;
}
/**
* 设置文件前缀
*
* @param string $prefix 文件前缀
*/
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
/**
* Lifecycle规则的状态
*
* @return string
*/
public function getStatus()
{
return $this->status;
}
/**
* 设置Lifecycle规则状态
*
* @param string $status
*/
public function setStatus($status)
{
$this->status = $status;
}
/**
*
* @return LifecycleAction[]
*/
public function getActions()
{
return $this->actions;
}
/**
* @param LifecycleAction[] $actions
*/
public function setActions($actions)
{
$this->actions = $actions;
}
/**
* LifecycleRule constructor.
*
* @param string $id 规则ID
* @param string $prefix 文件前缀
* @param string $status 规则状态,可选[self::LIFECYCLE_STATUS_ENABLED, self::LIFECYCLE_STATUS_DISABLED]
* @param LifecycleAction[] $actions
*/
public function __construct($id, $prefix, $status, $actions)
{
$this->id = $id;
$this->prefix = $prefix;
$this->status = $status;
$this->actions = $actions;
}
/**
* @param \SimpleXMLElement $xmlRule
*/
public function appendToXml(&$xmlRule)
{
$xmlRule->addChild('ID', $this->id);
$xmlRule->addChild('Prefix', $this->prefix);
$xmlRule->addChild('Status', $this->status);
foreach ($this->actions as $action) {
$action->appendToXml($xmlRule);
}
}
private $id;
private $prefix;
private $status;
private $actions = array();
const LIFECYCLE_STATUS_ENABLED = 'Enabled';
const LIFECYCLE_STATUS_DISABLED = 'Disabled';
}
\ No newline at end of file
<?php
namespace OSS\Model;
/**
* Class ListMultipartUploadInfo
* @package OSS\Model
*
* @link http://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/ListMultipartUploads.html
*/
class ListMultipartUploadInfo
{
/**
* 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
*/
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;
}
/**
* 得到bucket名称
*
* @return string
*/
public function getBucket()
{
return $this->bucket;
}
/**
* @return string
*/
public function getKeyMarker()
{
return $this->keyMarker;
}
/**
*
* @return string
*/
public function getUploadIdMarker()
{
return $this->uploadIdMarker;
}
/**
* @return string
*/
public function getNextKeyMarker()
{
return $this->nextKeyMarker;
}
/**
* @return string
*/
public function getNextUploadIdMarker()
{
return $this->nextUploadIdMarker;
}
/**
* @return string
*/
public function getDelimiter()
{
return $this->delimiter;
}
/**
* @return string
*/
public function getPrefix()
{
return $this->prefix;
}
/**
* @return int
*/
public function getMaxUploads()
{
return $this->maxUploads;
}
/**
* @return string
*/
public function getIsTruncated()
{
return $this->isTruncated;
}
/**
* @return UploadInfo[]
*/
public function getUploads()
{
return $this->uploads;
}
private $bucket = "";
private $keyMarker = "";
private $uploadIdMarker = "";
private $nextKeyMarker = "";
private $nextUploadIdMarker = "";
private $delimiter = "";
private $prefix = "";
private $maxUploads = 0;
private $isTruncated = "false";
private $uploads = array();
}
\ No newline at end of file
<?php
namespace OSS\Model;
/**
* Class ListPartsInfo
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/ListParts.html
*/
class ListPartsInfo
{
/**
* ListPartsInfo constructor.
* @param string $bucket
* @param string $key
* @param string $uploadId
* @param int $nextPartNumberMarker
* @param int $maxParts
* @param string $isTruncated
* @param array $listPart
*/
public function __construct($bucket, $key, $uploadId, $nextPartNumberMarker, $maxParts, $isTruncated, array $listPart)
{
$this->bucket = $bucket;
$this->key = $key;
$this->uploadId = $uploadId;
$this->nextPartNumberMarker = $nextPartNumberMarker;
$this->maxParts = $maxParts;
$this->isTruncated = $isTruncated;
$this->listPart = $listPart;
}
/**
* @return string
*/
public function getBucket()
{
return $this->bucket;
}
/**
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* @return string
*/
public function getUploadId()
{
return $this->uploadId;
}
/**
* @return int
*/
public function getNextPartNumberMarker()
{
return $this->nextPartNumberMarker;
}
/**
* @return int
*/
public function getMaxParts()
{
return $this->maxParts;
}
/**
* @return string
*/
public function getIsTruncated()
{
return $this->isTruncated;
}
/**
* @return array
*/
public function getListPart()
{
return $this->listPart;
}
private $bucket = "";
private $key = "";
private $uploadId = "";
private $nextPartNumberMarker = 0;
private $maxParts = 0;
private $isTruncated = "";
private $listPart = array();
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment