lixunguan/qiniu

There is no license information available for the latest version (dev-master) of this package.

laravel qiniu sdk

dev-master 2014-09-12 12:20 UTC

This package is not auto-updated.

Last update: 2024-12-17 08:49:25 UTC


README

七牛云存储非官方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 为私有文件