PHP code example of qgmac / cloud_object_storage
1. Go to this page and download the library: Download qgmac/cloud_object_storage 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/ */
qgmac / cloud_object_storage example snippets
$config = [
'default' => 'cos',//默认
'disks' => [
'cos' => [// 腾讯云
'driver' => 'cos',
'secret_id' => '',
'secret_key' => '',
'region' => '',
'bucket' => '',
'url' => '',
],
'obs' => [// 华为云
'driver' => 'obs',
'key' => '',
'secret' => '',
'bucket' => '',
'url' => '',
'endpoint' => '',
],
'oss' => [// 阿里云
'driver' => 'obs',
'key' => '',
'secret' => '',
'role_arn' => '',//即需要扮演的角色ID,格式为acs:ram::$accountID:role/$roleName
'bucket' => '',
'url' => '',
'endpoint' => '',
],
],
];
$store_key = "/test/test.jpg";
$manager = new Manager($config);
$default_store_url = $manager->store()->uploadFile($_file, $head_url);
$cos_url = $manager->store('cos')->uploadFile($_file, $head_url);
$obs_url = $manager->store('obs')->uploadFile($_file, $head_url);
$oss_url = $manager->store('oss')->uploadFile($_file, $head_url);
$manager->store('cos')->deleteFile($store_key) bool;
$manager->store('cos')->getFileUrl($store_key) string;
$manager->store('cos')->exist($store_key) bool;