2017 © Pedro Peláez
 

library laravel-oss

image

naux/laravel-oss

  • Saturday, July 28, 2018
  • by NauxLiu
  • Repository
  • 2 Watchers
  • 26 Stars
  • 146 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 10 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Laravel-Oss

专用于Laravel的阿里云OSS扩展包, (*1)

安装

添加依赖

添加, (*2)

"naux/laravel-oss": "1.*"

到你的composer.json文件的require中, 执行composer installcomposer update。, (*3)

注册Provider

在你的 config/app.php文件 providers数组中中添加'Naux\LaravelOss\LaravelOssServiceProvider'。, (*4)

配置

执行命令php artisan config:publish naux/laravel-oss
然后到app/config/packages/naux/laravel-oss/config.php文件中按照注释修改配置。, (*5)

实例

//删除bucket foo下的bar对象
OSS::bucket('foo')->delete('bar');

//上面选择了bucket,后面的操作都不用重复

//上传请求中的文件
OSS::upload('foobar', Input::file('image'));

//取得directory目录下的所有对象信息
foreach(OSS::files('directory') as $file){
    //do something
}

使用

获取原生OSSClient对象

OSS::getClient();

选择bucket

OSS::bucket('foo');

如果在配置文件中设置了default字段,就不需要选择, (*6)

删除bucket

OSS::bucket('foo')->destroy();

创建新的bucket

OSS::create('foo');

//创建bucket同时设置权限
OSS::create('foo', 'public');

权限选项:
1. private私有(默认)
2. public-read公共读
3. public-read-write 公共读写, (*7)

获取所有bucket

//当前账号拥有的所有bucket
OSS::buckets();

上传文件

//根据路径上传文件
OSS::upload('foobar', '/temps/file');

//上传文件,同时设置其他信息
OSS::upload('foobar', '/temps/file', [
    'Expires' => new \DateTime("+5 minutes"),
    'Content-Type' => 'foo',
    //...
]);

//上传请求中的文件
OSS::update('foobar', Input::file('foobar'));

使用Input::file()上传的文件,会被自动设置ContentType, (*8)

删除object

OSS::delete('object_key');

//同时删除多个
OSS::delete(['object_key1', 'object_key2']);

拷贝Object

OSS::copy('from', 'to');

//从当前的bucket拷贝到其他bucket
OSS::copy('from', 'to', 'another_bucket');

移动Object

OSS::move('from', 'to');

//从当前的bucket其他bucket并重命名
OSS::move('from', 'to', 'another_bucket');

获取所有Object列表

OSS::objects();

//方法声明
//public function objects($start = 0, $limit = 100, $prefix = '', $delimiter = ''){}

参数 参考文档, (*9)

获取指定目录下Object列表

//获得temps目录下所有object列表
OSS::files('temps');

The Versions

28/07 2018

dev-master

9999999-dev

  Sources   Download

The Requires

 

11/02 2015

1.3

1.3.0.0

  Sources   Download

The Requires

 

10/02 2015

1.2

1.2.0.0

  Sources   Download

The Requires

 

28/01 2015

v1.1

1.1.0.0

  Sources   Download

The Requires

 

28/01 2015

v1.0

1.0.0.0

  Sources   Download

The Requires