Package Data | |
---|---|
Maintainer Username: | kayson |
Maintainer Contact: | kayson@huida.cn (kayson) |
Package Create Date: | 2022-02-24 |
Package Last Update: | 2022-02-24 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-18 03:01:52 |
Package Statistics | |
---|---|
Total Downloads: | 465 |
Monthly Downloads: | 20 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
English | 中文
ps: The comparison of similar projects is only to highlight the differences. In fact, they are all very good.
Run the following command to pull in the latest version:
composer require illusionist/flysystem-aliyun-oss
If your laravel version <=5.4
, Add the service provider to the providers
array in the config/app.php
config file as follows:
'providers' => [
...
Illusionist\Flysystem\Aliyun\OssServiceProvider::class,
]
Add the following snippet to the bootstrap/app.php
file under the providers section as follows:
...
// Add this line
$app->register(Illusionist\Flysystem\Aliyun\OssServiceProvider::class);
Add the adapter config to the disks
array in the config/filesystems.php
config file as follows:
'disks' => [
...
'aliyun-oss' => [
'driver' => 'aliyun-oss',
/**
* The AccessKeyId from OSS or STS.
*/
'key' => '<your AccessKeyId>',
/**
* The AccessKeySecret from OSS or STS
*/
'secret' => '<your AccessKeySecret>',
/**
* The domain name of the datacenter.
*
* @example: oss-cn-hangzhou.aliyuncs.com
*/
'endpoint' => '<endpoint address>',
/**
* The bucket name for the OSS.
*/
'bucket' => '<bucket name>',
/**
* The security token from STS.
*/
'token' => null,
/**
* If this is the CName and binded in the bucket.
*
* Values: true or false
*/
'cname' => false,
/**
* Path prefix
*/
'prefix' => '',
/**
* Request header options.
*
* @example [x-oss-server-side-encryption => 'KMS']
*/
'options' => []
]
]
Please refer to filesystem-api.
use Illusionist\Flysystem\Aliyun\OssAdapter;
use League\Flysystem\Filesystem;
use OSS\OssClient;
$client = new OssClient(
'<your AccessKeyId>',
'<your AccessKeySecret>',
'<endpoint address>'
);
$adapter = new OssAdapter($client, '<bucket name>', 'optional-prefix', 'optional-options');
$filesystem = new Filesystem($adapter);
$filesystem->has('file.txt');
// Dynamic call SDK method.
$adapter->setTimeout(30);
$filesystem->getAdapter()->setTimeout(30);
Please refer to filesystem
use Illuminate\Support\Facades\Storage;
Storage::disk('aliyun-oss')->get('path');
// Dynamic call SDK method.
Storage::disk('aliyun-oss')->getAdapter()->setTimeout(30);