PHP code example of byrnes2014 / laravel-filesystem-oss

1. Go to this page and download the library: Download byrnes2014/laravel-filesystem-oss library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

byrnes2014 / laravel-filesystem-oss example snippets


Jacobcyl\AliOSS\AliOssServiceProvider::class,


'disks'=>[
    ...
    'oss' => [
            'driver'        => 'oss',
            'access_id'     => '<Your Aliyun OSS AccessKeyId>',
            'access_key'    => '<Your Aliyun OSS AccessKeySecret>',
            'bucket'        => '<OSS bucket name>',
            'endpoint'      => '<the endpoint of OSS, E.g: oss-cn-hangzhou.aliyuncs.com | custom domain, E.g:img.abc.com>', 
            'isCName'       => <true|false> 
            'debug'         => <true|false>
    ],
    ...
]

use Illuminate\Support\Facades\Storage;

Storage::disk('oss'); // if default filesystems driver is oss, you can skip this step

Storage::put('path/to/file/file.jpg', $contents)