PHP code example of cdcchen / upyun-client

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

    

cdcchen / upyun-client example snippets


use cdcchen\upyun\UpYunClient;

$bucketName = '';
$username = '';
$password = '';
$client = new UpYunClient($bucketName, $username, $password);

try {
    $result = $client->writeFile($distFile, $srcFile);
    print_r($result);
} catch (\cdcchen\upyun\ResponseException $e) {
    echo $e->getMessage(), $e->getCode(), PHP_EOL;
} catch (Exception $e) {
    echo $e->getCode(), $e->getMessage(), PHP_EOL;
}

$data = $client->readFile($file);

$data = $client->deleteFile($file);

$data = $client->getFileInfo($file);

$result = $client->createDir($path, $mkdir = true);

$result = $client->deleteDir($path);

$data = $client->readDir($path);

$delimiter = '!';
$maker = new UrlImageMaker($url, $delimiter);
$maker->fw(200)->scale(2);
$url = $maker->getUrl();

$data = $client->getBucketUsage();