You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.6 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
require('./include.php');
use qcloudcos\Cosapi;
$bucket = 'qiluwansy';
$src = './20170315164427_146.apk';
$dst = '/testfolder/20170315164427_146.apk';
$folder = '/testfolder';
Cosapi::setTimeout(0);
// 设置COS所在的区域对应关系如下
// 华南 -> gz
// 华中 -> sh
// 华北 -> tj
Cosapi::setRegion('sh');
// Create folder in bucket.
// $ret = Cosapi::createFolder($bucket, $folder);
// var_dump($ret);
// Upload file into bucket.
$ret = Cosapi::upload($bucket, $src, $dst);
var_dump($ret);
// List folder.
// $ret = Cosapi::listFolder($bucket, $folder);
// var_dump($ret);
// // Update folder information.
// $bizAttr = "";
// $ret = Cosapi::updateFolder($bucket, $folder, $bizAttr);
// var_dump($ret);
// // Update file information.
// $bizAttr = '';
// $authority = 'eWPrivateRPublic';
// $customerHeaders = array(
// 'Cache-Control' => 'no',
// 'Content-Type' => 'application/pdf',
// 'Content-Language' => 'ch',
// );
// $ret = Cosapi::update($bucket, $dst, $bizAttr,$authority, $customerHeaders);
// var_dump($ret);
// // Stat folder.
// $ret = Cosapi::statFolder($bucket, $folder);
// var_dump($ret);
// // Stat file.
// $ret = Cosapi::stat($bucket, $dst);
// var_dump($ret);
// // Copy file.
// $ret = Cosapi::copyFile($bucket, $dst, $dst . '_copy');
// var_dump($ret);
// // Move file.
// $ret = Cosapi::moveFile($bucket, $dst, $dst . '_move');
// var_dump($ret);
// // Delete file.
// $ret = Cosapi::delFile($bucket, $dst . '_copy');
// var_dump($ret);
// $ret = Cosapi::delFile($bucket, $dst . '_move');
// var_dump($ret);
// // Delete folder.
// $ret = Cosapi::delFolder($bucket, $folder);
// var_dump($ret);