xinningsu/laravel-filesystem-baidu-bos 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xinningsu/laravel-filesystem-baidu-bos

最新稳定版本:v1.0.2

Composer 安装命令:

composer require xinningsu/laravel-filesystem-baidu-bos

包简介

Baidu BOS storage for Laravel, 百度对象存储作为Laravel文件存储。

README 文档

README

Baidu BOS storage for Laravel, 百度对象存储作为Laravel文件存储。

MIT licensed Build Status Code Coverage Scrutinizer Code Quality Code Intelligence Status Maintainability

Installation

composer require xinningsu/laravel-filesystem-baidu-bos

Discovery

  • For Laravel >= 5.5, It uses package auto discovery feature, no need to add service provider.
  • For Laravel < 5.5, add Sulao\LaravelFilesystem\BaiduBos\BaiduBosServiceProvider::class to config/app.php under providers element.
return [
    // ...
    'providers' => [
        // ...
        /*
         * Package Service Providers...
         */
        Sulao\LaravelFilesystem\BaiduBos\BaiduBosServiceProvider::class,
    ],
    // ...
];

Configuration

Set up bos credentials in .env, then add new disk in config/filesystems.php:

return [
    // ...
    'disks' => [
        // ...
        'bos' => [
            'driver' => 'bos',
            'access_key' => env('BOS_KEY'),
            'secret_key' => env('BOS_SECRET'),
            'region' => env('BOS_REGION'), // gz, bj ...
            'bucket' => env('BOS_BUCKET'),
        ],
        // ...
    ],
    // ...
];

Examples

$disk = \Illuminate\Support\Facades\Storage::disk('bos');

// Determine if a file exists.
$disk->exists('file.txt');

// Get the contents of a file.
$content = $disk->get('file.txt');

// Get a resource to read the file.
$stream = $disk->readStream('file.txt');

// Write the contents of a file.
$disk->put('file.txt', 'contents');

// Write a new file using a stream.
$disk->writeStream('file.txt', fopen('/resource.txt', 'r'));

// Get the visibility for the given path.
$visibility = $disk->getVisibility('file.txt');

// Set the visibility for the given path.
$disk->setVisibility('file.txt', 'public');

// Prepend to a file.
$disk->prepend('file.txt', 'prepend contents');

// Append to a file.
$disk->append('file.txt', 'append contents');

// Delete the file(s) at a given path.
$disk->delete('file.txt');
$disk->delete(['file.txt', 'file2.txt']);

// Copy a file to a new location.
$disk->copy('file.txt', 'new_file.txt');

// Move a file to a new location.
$disk->move('file.txt', 'new_file.txt');

// Get the file size of a given file.
$size = $disk->size('file.txt');

// Get the file's last modification time.
$ts = $disk->lastModified('file.txt');

// Get an array of all files in a directory.
$files = $disk->files($directory = 'test/', $recursive = false);

// Get all of the files from the given directory (recursive).
$allFiles = $disk->allFiles($directory = null);

// Get all of the directories within a given directory.
$dirs = $disk->directories($directory = null, $recursive = false);

// Get all (recursive) of the directories within a given directory.
$allDirs = $disk->allDirectories($directory = null);

// Create a directory.
$disk->makeDirectory('test/');

// Delete a directory.
$disk->deleteDirectory('test/');

Reference

License

MIT

统计信息

  • 总下载量: 1.37k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-05