[md]
//需要删除的文件夹路径
$file_url_server = 'demo/removeDir/';
//引用jdk
require_once(ROOT_PATH .'vendor/ali_oss/samples/Common.php');
$bucketName = \Common::getBucketName();
$ossClient = \Common::getOssClient();
$file_url_server = rtrim($file_url_server, '/').'/';
$options = [
'delimiter' => '/',
'prefix' => $file_url_server,
'max-keys' => 1000, //最多1000个
'marker' => '',
];
//获取文件列表
$response = $ossClient->listObjects($bucketName, $options);
$fileList = $response->getObjectList();
$delObj = [];
foreach ($fileList as $v) {
$keyName = $v->getKey();
$delObj[] = $keyName;
}
if($delObj) {
$ossClient->deleteObjects($bucketName, $delObj);
}