PHP code example of johnlui / aliyun-oss-laravel7

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

    

johnlui / aliyun-oss-laravel7 example snippets


... ...

  private $city = '青岛';

  // 经典网络 or VPC
  private $networkType = '经典网络';
  
  private $AccessKeyId = '';
  private $AccessKeySecret = '';

... ...

use App\Services\OSS;

// 在外网上传一个文件并指定 options 如:Content-Type 类型
// 更多 options 见:https://github.com/johnlui/AliyunOSS/blob/master/src/oss/src/Aliyun/OSS/OSSClient.php#L142-L148
OSS::publicUpload('bucket', '目标 object 名', '本地文件绝对路径', [
    'ContentType' => 'application/pdf',
    ... ...
]);

use AppBundle\Services\OSS;

OSS::publicUpload('bucket', '目标 object 名', '本地文件绝对路径');