About
Enhanced Qiniu SDK
Installation
Require this package with composer:
composer require songshenzong/qiniu
Laravel
Publish configuration files. If not, They can not be serialized correctly when you execute the config:cache
Artisan command.
php artisan vendor:publish --provider="Songshenzong\Qiniu\ServiceProvider"
Common Method
public function qiniu()
{
return qiniu('Key', 'secret') -> bucket('bucketName')
-> domain('http://my.com/')
-> prefix('project_name')
-> addPrefix('dev');
}
Put File
$file = request() -> file('file');
list($success, $error) = $this -> qiniu() -> putFile($file);
if ($error !== null) {
return $error;
} else {
return $success;
}
Success Return
{
"hash": "FrNDCStnjFNdyTZSOj0MlcW7vW4Y",
"key": "project_name/dev/b4937112-288c-3a98-a630-f33034a28650.jpg",
"url": "http://my.com/project_name/dev/b4937112-288c-3a98-a630-f33034a28650.jpg"
}
Use Qiniu Key
putFile($file,true);
Success Return
{
"hash": "FrNDCStnjFNdyTZSOj0MlcW7vW4Y",
"key": "FrNDCStnjFNdyTZSOj0MlcW7vW4Y",
"url": "http://my.com/FrNDCStnjFNdyTZSOj0MlcW7vW4Y"
}
Put Data
list($success, $error) = $this -> qiniu() -> put('love.txt','I Love U');
if ($error !== null) {
return $error;
} else {
return $success;
}
Delete
return $this -> qiniu() -> delete($key);
Documentation
Please refer to our extensive Wiki documentation for more information.
Support
For answers you may not find in the Wiki, avoid posting issues. Feel free to ask for support on Songshenzong.com
License
This package is licensed under the BSD 3-Clause license.