PHP code example of overtrue / laravel-filesystem-qiniu

1. Go to this page and download the library: Download overtrue/laravel-filesystem-qiniu 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/ */

    

overtrue / laravel-filesystem-qiniu example snippets


'providers' => [
    // Other service providers...
    Overtrue\LaravelFilesystem\Qiniu\QiniuStorageServiceProvider::class,
],



return [
   'disks' => [
        //...
        'qiniu' => [
           'driver'     => 'qiniu',
           'access_key' => env('QINIU_ACCESS_KEY', 'xxxxxxxxxxxxxxxx'),
           'secret_key' => env('QINIU_SECRET_KEY', 'xxxxxxxxxxxxxxxx'),
           'bucket'     => env('QINIU_BUCKET', 'test'),
           'domain'     => env('QINIU_DOMAIN', 'xxx.clouddn.com'), // or host: https://xxxx.clouddn.com
        ],
        //...
    ]
];

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

// 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');

// 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->getAdapter()->fetch('folder/save_as.txt', $fromUrl);

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

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

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