crackqing / laravel-filesystem-obs by crackqing

huawei cloud obs filesystem storage for laravel 5+ or Lumen
13
0
1
Package Data
Maintainer Username: crackqing
Package Create Date: 2023-02-21
Package Last Update: 2023-02-21
Language: PHP
License: MIT
Last Refreshed: 2024-11-18 03:00:21
Package Statistics
Total Downloads: 13
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Huawei Cloud OBS for Laravel

Huawei Cloud OBS storage for Laravel based on wangqs/laravel-filesystem-obs.

  • 只适用公司产品,修复高版本兼容问题.
  • Lumen5.8版本适配能过

Requirement

  • PHP >= 7.3

Installation

$ composer require "jkyang/laravel-filesystem-obs" -vvv

Configuration

  1. After installing the library, register the jkyang\Obs\ObsServiceProvider in your config/app.php file:
'providers' => [
    // Other service providers...
    jkyang\Obs\ObsServiceProvider::class,
],
  1. Add a new disk to your config/filesystems.php config:
<?php

return [
   'disks' => [
       //...
       'obs' => [
           'driver' => 'obs',
           'key' => env('OBS_ACCESS_ID'), // <AccessKeyId>
           'secret' => env('OBS_ACCESS_KEY'), // <OBS AccessKeySecret>
           'bucket' => env('OBS_BUCKET'), // <OBS bucket name>
           'endpoint' => env('OBS_ENDPOINT'), // <the endpoint of OBS, E.g: (https:// or http://).obs.cn-east-2.myhuaweicloud.com | custom domain, E.g:img.abc.com> 
           'cdn_domain' => env('OBS_CDN_DOMAIN'), //<CDN domain>
           'ssl_verify' => env('OBS_SSL_VERIFY'), // <true|false> true to use 'https://' and false to use 'http://'. default is false,
           'debug' => env('APP_DEBUG'), // <true|false>
       ],
       //...
    ]
];

Usage

$disk = Storage::disk('obs');

// create a file
$disk->put('avatars/filename.jpg', $fileContents);

// check if a file exists
$exists = $disk->has('file.jpg');

// get timestamp
$time = $disk->lastModified('file1.jpg');
$time = $disk->getTimestamp('file1.jpg');

// copy a file
$disk->copy('old/file1.jpg', 'new/file1.jpg');

// move a file
$disk->move('old/file1.jpg', 'new/file1.jpg');

// get file contents
$contents = $disk->read('folder/my_file.txt');

// fetch url content
$file = $disk->fetch('folder/save_as.txt', $fromUrl);

// get file url
$url = $disk->getUrl('folder/my_file.txt');

// get file upload token
$token = $disk->getUploadToken('folder/my_file.txt');
$token = $disk->getUploadToken('folder/my_file.txt', 3600);

// get private url
$url = $disk->privateDownloadUrl('folder/my_file.txt');

Full API documentation.

License

MIT