LyleLai / laravel-filesystem-qiniu by LyleLai
forked from overtrue/laravel-filesystem-qiniu

A Qiniu storage filesystem for Laravel.
23
0
2
Package Data
Maintainer Username: LyleLai
Maintainer Contact: i@overtrue.me (overtrue)
Package Create Date: 2017-07-28
Package Last Update: 2017-07-28
Language: PHP
License: MIT
Last Refreshed: 2024-04-27 03:12:35
Package Statistics
Total Downloads: 23
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Laravel filesystem Qiniu

Qiniu storage for Laravel based on overtrue/flysystem-qiniu.

Requirement

  • PHP >= 5.5.9

Installation

$ composer require "overtrue/laravel-filesystem-qiniu" -vvv

Configuration

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

return [
    //...
    '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
    ],
    //...
];

Usage

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

// create a file
$disk->put('avatars/1', $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');

Full API documentation.

License

MIT