七牛云存储非官方SDK,采用PSR规范,支持Composer安装
添加 "lixunguan/qiniu": "*"
到 composer.json
.
composer.phar install
打开app.php 给aliases 加上 'Qiniu' => 'Lixunguan\Qiniu\Storage'
return Qiniu::make(array(
'access_key' => Config::get('app.upload_access_key'),
'secret_key' => Config::get('app.upload_secret_key'),
'bucket' => Config::get('app.upload_bucket')
))->info('uploads/2014/0910/31c0497aefbf45a22822e9761660a61e.jpg');
输出
Array
(
[fsize] => 69478
[hash] => FkkMiEQKOsHOAkQOsA0zZ8Noxsf2
[mimeType] => image/jpeg
[putTime] => 1.4103365664006E+16
)
return Qiniu::make(array(
'access_key' => Config::get('app.upload_access_key'),
'secret_key' => Config::get('app.upload_secret_key'),
'bucket' => Config::get('app.upload_bucket')
))->copy('uploads/2014/0910/31c0497aefbf45a22822e9761660a61e.jpg', 'new.jpg');
输出
如果请求成功,不返回任何内容。
如果请求失败,返回包含如下内容:
Array(
[code] => HTTP状态码
[error] => 与HTTP状态码对应的消息文本
)
return Qiniu::make(array(
'access_key' => Config::get('app.upload_access_key'),
'secret_key' => Config::get('app.upload_secret_key'),
'bucket' => Config::get('app.upload_bucket')
))->move('new.jpg', 'move.jpg');
输出
如果请求成功,不返回任何内容。
如果请求失败,返回包含如下内容:
Array(
[code] => HTTP状态码
[error] => 与HTTP状态码对应的消息文本
)
return Qiniu::make(array(
'access_key' => Config::get('app.upload_access_key'),
'secret_key' => Config::get('app.upload_secret_key'),
'bucket' => Config::get('app.upload_bucket')
))->delete('new.jpg');
输出
如果请求成功,不返回任何内容。
如果请求失败,返回包含如下内容:
Array(
[code] => HTTP状态码
[error] => 与HTTP状态码对应的消息文本
)
return Qiniu::make(array(
'access_key' => Config::get('app.upload_access_key'),
'secret_key' => Config::get('app.upload_secret_key'),
'bucket' => Config::get('app.upload_bucket')
))->lists(array('prefix' => 'uploads/2010')); // 指定前缀搜索
return Qiniu::make(array(
'access_key' => Config::get('app.upload_access_key'),
'secret_key' => Config::get('app.upload_secret_key'),
'bucket' => Config::get('app.upload_bucket')
))->upload('123.jpg', 'uploads/123.jpg');
return Qiniu::make(array(
'access_key' => Config::get('app.upload_access_key'),
'secret_key' => Config::get('app.upload_secret_key'),
'bucket' => Config::get('app.upload_bucket')
))->download($value, true); // true 为私有文件