enochzg / yii2-aliyun-oss
yii2-aliyun-oss
Installs: 61
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Type:yii2-extension
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2025-01-18 20:30:16 UTC
README
阿里云OSS云存储SDK封装
安装
composer require enochzg/yii2-aliyun-oss
配置
<?php 'aliyun' => [ 'class' => 'enochzg\aliyun\Aliyun', 'accessKeyId' => '', //在阿里云的控制台可以创建、查询 'accessSecret' => '', //在阿里云的控制台可以创建、查询 'defaultRoleArn' => '', //在阿里云的控制台可以创建、查询 'defaultBucketName' => '', //默认操作哪个BucketName 'endPoint' => 'oss-cn-shenzhen.aliyuncs.com', ], ?>
使用方式
<?php //生成临时授权凭证 $sessionName = '99'; $durationSeconds = 3600; //过期时间 $token = yii::$app->aliyun->generateSTSToken($sessionName, $durationSeconds); //上传文件,默认操作defaultBucketName yii::$app->aliyun->uploadFile('enoch-test', '/home/enoch/图片/2.png'); //单个文件删除,默认操作defaultBucketName yii::$app->aliyun->deleteObject('object-name', 'bucketName'); //批量删除文件,默认操作defaultBucketName yii::$app->aliyun->deleteObjects(['path/58ca9c-f', 'path/929171a3']); ?>