apollopy/flysystem-aliyun-oss

这是为 Aliyun OSS ~2.3 定制的 Flysystem 适配器

1.2.1 2020-01-19 08:30 UTC

This package is auto-updated.

Last update: 2024-09-19 18:52:28 UTC


README

这是为 Aliyun OSS ~2.3 定制的 Flysystem 适配器

灵感来源于 aobozhang/aliyun-oss-adapter

安装

composer require apollopy/flysystem-aliyun-oss

对于 Laravel

必须注册此服务提供者。

// config/app.php

'providers' => [
    '...',
    ApolloPY\Flysystem\AliyunOss\AliyunOssServiceProvider::class,
];

编辑配置文件:config/filesystems.php

添加配置

'oss' => [
    'driver'     => 'oss',
    'access_id'  => env('OSS_ACCESS_ID','your id'),
    'access_key' => env('OSS_ACCESS_KEY','your key'),
    'bucket'     => env('OSS_BUCKET','your bucket'),
    'endpoint'   => env('OSS_ENDPOINT','your endpoint'),
    'prefix'     => env('OSS_PREFIX', ''), // optional
],

将默认存储更改为 oss

    'default' => 'oss'

使用

查看 Laravel 维基

插件

灵感来源于 itbdw/laravel-storage-qiniu

Storage::disk('oss')->putFile($md5_path, '/local_file_path/1.png', ['mimetype' => 'image/png','filename' => 'filename_by_down.png']);

Storage::disk('oss')->signedDownloadUrl($path, 3600, 'oss-cn-beijing.aliyuncs.com', true);

IDE 辅助

如果已安装 barryvdh/laravel-ide-helper

编辑配置文件:config/ide-helper.php

'interfaces'      => [
    '\Illuminate\Contracts\Filesystem\Filesystem' => ApolloPY\Flysystem\AliyunOss\FilesystemAdapter::class,
],