PHP code example of naux / laravel-oss
1. Go to this page and download the library: Download naux/laravel-oss library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
naux / laravel-oss example snippets
//删除bucket foo下的bar对象
OSS::bucket('foo')->delete('bar');
//上面选择了bucket,后面的操作都不用重复
//上传请求中的文件
OSS::upload('foobar', Input::file('image'));
//取得directory目录下的所有对象信息
foreach(OSS::files('directory') as $file){
//do something
}
OSS::bucket('foo');
OSS::bucket('foo')->destroy();
OSS::create('foo');
//创建bucket同时设置权限
OSS::create('foo', 'public');
//当前账号拥有的所有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'));
OSS::delete('object_key');
//同时删除多个
OSS::delete(['object_key1', 'object_key2']);
OSS::copy('from', 'to');
//从当前的bucket拷贝到其他bucket
OSS::copy('from', 'to', 'another_bucket');
OSS::move('from', 'to');
//从当前的bucket其他bucket并重命名
OSS::move('from', 'to', 'another_bucket');
OSS::objects();
//方法声明
//public function objects($start = 0, $limit = 100, $prefix = '', $delimiter = ''){}
//获得temps目录下所有object列表
OSS::files('temps');