PHP code example of juhedata / aliyun-oss

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

    

juhedata / aliyun-oss example snippets


... ...

  private $city = '青岛';

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

  private $AccessKeyId = '';
  private $AccessKeySecret = '';

... ...

use App\Services\OSS;

// 在外网上传一个文件并指定 options 如:Content-Type 类型
// 更多 options 见:https://github.com/juhedata/aliyun-oss/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 名', '本地文件绝对路径');