PHP code example of chenhua / laravel5-aliyun-oss

1. Go to this page and download the library: Download chenhua/laravel5-aliyun-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/ */

    

chenhua / laravel5-aliyun-oss example snippets


Chenhua\AliyunOss\AliyunOssServiceProvider::class,

'AliyunOss' => Chenhua\AliyunOss\Facades\AliyunOss::class,

use AliyunOss;

#code
//自定义bucket
$bucket = '81f7-test';

//生成文件不带前缀
$file = AliyunOss::uploadFileByUrl('http://www.81f7.com/logo.png',$bucket);

//生成文件带 rc 前缀
$file = AliyunOss::uploadFileByUrl('http://www.81f7.com/logo.png',$bucket,'rc');

use AliyunOss;

#code
//自定义bucket
$bucket = '81f7-test';
$file_name = 'logo.png';

//获取已有文件信息
$getFile = AliyunOss::getObjectMeta($bucket, $file_name);

//AliyunOss::getObjectMeta($bucket, $file_name);
//实际调用的是 `OSS/OssClient.php` 中的:
//public function getObjectMeta($bucket, $object, $options = NULL)

bash
php artisan vendor:publish --tag=aliyun.oss