Cloud storage capabilities with seven KN cloud storage integrated in Laravel 5

Source: Internet
Author: User
This expansion pack is based on HTTPS://GITHUB.COM/QINIU/PHP-SDK and is a seven cow cloud storage laravel 5Storage, which integrates seven cow cloud storage capabilities in Laravel 5.

1. Installation Configuration

Before use, install via composer:

Composer require zgldh/qiniu-laravel-storage

Then register the service provider in config/app.php:

Zgldh\qiniustorage\qiniufilesystemserviceprovider::class

Next, add the following options to the disks in config/filesystems.php:

' Disks ' = [        ...,        ' qiniu ' = ['            driver ' = '  qiniu ',            ' domains ' and ' = ' [                ' Default '   ] = ' laravelacademy.com1.z0.glb.clouddn.com ',//your seven KN domain name                ' https '     = ' dn-laravelacademy.qbox.me ',         / /your HTTPS domain name                ' custom '    = ' static.laravelacademy.org ',     //Your custom domain name             ],            ' access_key ' = ' ',  //accesskey            ' secret_key ' = ', '  //secretkey '            bucket '    = ',  //bucket name            ' notify_url ' = ' + '  ,//Persistent callback address        ]    ,

2. Use

The first usage:

$disk = \storage::d ISK (' Qiniu '); $disk->exists (' file.jpg ');                         Whether the file exists $disk->get (' file.jpg ');               Get file Content $disk->put (' file.jpg ', $contents);   Upload file $disk->prepend (' File.log ', ' Prepended Text ');     Append content to the beginning of the file $disk->append (' File.log ', ' appended Text ');                      Append content to the end of file $disk->delete (' file.jpg ');  Delete File $disk->delete ([' file1.jpg ', ' file2.jpg ']), $disk->copy (' old/file1.jpg ', ' new/file1.jpg ');  Copy the file to the new path $disk->move (' old/file1.jpg ', ' new/file1.jpg ');               Move the file to the new path $size = $disk->size (' file1.jpg ');       Get file Size: + = $disk->lastmodified (' file1.jpg ');              Get last Modified (UNIX) $files = $disk->files ($directory);               Get all Files under directory $files = $disk->allfiles ($directory); This is not realized ...      $directories = $disk->directories ($directory); This is not realized ...   $directories = $disk->alldirectories ($directory); This is not realized ...               $disk->makedirectory ($directory); This actuallyWithout any effect $disk->deletedirectory ($directory);                Delete directories, including all sub-files subdirectories under directory $disk->getdriver ()->uploadtoken (' file.jpg ');                Get upload Token$disk->getdriver ()->downloadurl (' file.jpg ');       Get download Address $disk->getdriver ()->downloadurl (' file.jpg ', ' https ');         Get HTTPS download Address $disk->getdriver ()->privatedownloadurl (' file.jpg '); Get the private bucket download Address $disk->getdriver ()->privatedownloadurl (' file.jpg ', ' https ');//Get HTTPS download address for private bucket $disk-                  >getdriver ()->imageinfo (' file.jpg ');                  Get picture Information $disk->getdriver ()->imageexif (' file.jpg ');                         Get pictures of EXIF information $disk->getdriver ()->imagepreviewurl (' file.jpg ', ' imageview2/0/w/100/h/200 '); Get Picture preview Url$disk->getdriver ()->persistentfop (' file.flv ', ' avthumb/m3u8/segtime/40/vcodec/libx264/s/   ");   Perform persistent data processing $disk->getdriver ()->persistentfop (' file.flv ', ' fop ', ' queue name '); Use private queues to perform persisted data processing $disk->getdriver ()->persistentstatus ($persistenT_FOP_ID); View the status of persisted data processing.

The second usage (which is omitting a getdriver):

Use zgldh\qiniustorage\qiniustorage; $disk = qiniustorage::d ISK (' Qiniu '); $disk->exists (' file.jpg ');                         Whether the file exists $disk->get (' file.jpg ');               Get file Content $disk->put (' file.jpg ', $contents);   Upload file $disk->prepend (' File.log ', ' Prepended Text ');     Append content to the beginning of the file $disk->append (' File.log ', ' appended Text ');                      Append content to the end of file $disk->delete (' file.jpg ');  Delete File $disk->delete ([' file1.jpg ', ' file2.jpg ']), $disk->copy (' old/file1.jpg ', ' new/file1.jpg ');  Copy the file to the new path $disk->move (' old/file1.jpg ', ' new/file1.jpg ');               Move the file to the new path $size = $disk->size (' file1.jpg ');       Get file Size: + = $disk->lastmodified (' file1.jpg ');              Get last Modified (UNIX) $files = $disk->files ($directory);               Get all Files under directory $files = $disk->allfiles ($directory); This is not realized ...      $directories = $disk->directories ($directory); This is not realized ...   $directories = $disk->alldirectories ($directory); This is not realized ... $disk->makedirEctory ($directory);             This actually does not have any effect $disk->deletedirectory ($directory);                     Delete directory, including all sub-file subdirectories under directory $disk->uploadtoken (' file.jpg ');                     Get upload token$disk->downloadurl (' file.jpg ');            Get the Download Address $disk->downloadurl (' file.jpg ', ' https ');              Get HTTPS Download Address $disk->privatedownloadurl (' file.jpg ');     Get the private bucket download address $disk->privatedownloadurl (' file.jpg ', ' https ');                       Gets the HTTPS download address for the private bucket $disk->imageinfo (' file.jpg ');                       Get picture information $disk->imageexif (' file.jpg ');                          Get pictures of EXIF information $disk->imagepreviewurl (' file.jpg ', ' imageview2/0/w/100/h/200 ');    Get Picture preview Url$disk->persistentfop (' file.flv ', ' avthumb/m3u8/segtime/40/vcodec/libx264/s/320x240 ');    Perform persistent data processing $disk->persistentfop (' file.flv ', ' fop ', ' queue name ');        Use private queues to perform persistent data processing $disk->persistentstatus ($persistent _fop_id); View the status of persisted data processing.

3. Related references

This extension pack GitHub address is https://github.com/zgldh/qiniu-laravel-storage, based on HTTPS://GITHUB.COM/QINIU/PHP-SDK development, For more information, please refer to the seven official PHP SDK usage guide: http://developer.qiniu.com/code/v7/sdk/php.html

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.