PHP code example of wangsucs / wcs-sdk-php

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

    

wangsucs / wcs-sdk-php example snippets




//bucketName 空间名称
//fileKey   自定义文件名
//localFile 上传文件名
//returnBody    自定义返回内容  (可选)
//userParam 自定义变量名    <x:VariableName>    (可选)
//userVars  自定义变量值    <x:VariableValue>   (可选)
//mimeType  自定义上传类型  (可选)

allbackUrl = '';

// 预处理
$pp->persistentOps = '<cmd>';

// token有效期,可自定义token有效期截止时间,值为毫秒时间戳;不指定时会按照WCS_TOKEN_DEADLINE配置的有效期计算截止时间戳
$pp->deadline = '<timestamp>'; 
$token = $pp->get_token();

$client = new Uploader($token, $userParam, $userVars, $mimeType);
$resp = $client->upload_return($localFile);
print_r($resp);

//bucketName 空间名称
//fileKey   自定义文件名
//localFile 上传文件名

ileKey == null || $fileKey === '') {
    $pp->scope = $bucketName;
} else {
    $pp->scope = $bucketName . ':' . $fileKey;
}

// token有效期,可自定义token有效期截止时间,值为毫秒时间戳;不指定时会按照WCS_TOKEN_DEADLINE配置的有效期计算截止时间戳
$pp->deadline = '<timestamp>'; 

$pp->persistentOps = $cmd;
$pp->persistentNotifyUrl = $notifyUrl;
$pp->returnBody = $returnBody;
$token = $pp->get_token();

$client = new ResumeUploader($token, $userParam, $encodeUserVars, $mimeType);
$client->upload($localFile);