当前位置:网站首页>OSS deletes all files two days before the current time
OSS deletes all files two days before the current time
2022-07-26 14:57:00 【Little Heilei】
Paste the script code directly , Anyway, it's almost caused by Alibaba cloud's case , It's just convenient for others to avoid building wheels again ,
require_once Is to introduce Alibaba cloud oss My bag ,
enumerate : If Alibaba cloud is introduced into any project oss, Most of the composer The introduction is in vendors Under the table of contents , Then you can directly ,require_once '/www/wwwhtml/ Project directory /vendor/aliyuncs/oss-sdk-php/autoload.php';
<?php
require_once './aliyun-oss-php-sdk-master/autoload.php';
static $oss = [
'key'=>'',
'secret'=>'',
'end_point'=>'http://oss-cn-shenzhen.aliyuncs.com',
'ALI_OSS_READ_URL'=>'',
'BUCKET'=>''
];
try {
$ossClient = new \OSS\OssClient($oss['key'], $oss['secret'], $oss['end_point']);
} catch (\OSS\Core\OssException $e) {
print $e->getMessage();
return;
}
try {
$listObjectInfo = $ossClient->doesBucketExist($oss['BUCKET']);
} catch (\OSS\Core\OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
$path = "audiores/".date("Ymd",strtotime("-2 day")).'/';
try{
(boolean) $exist = $ossClient->doesObjectExist($oss['BUCKET'], $path);
if(!$exist){
return 'ok';
}
} catch(\OSS\Core\OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
echo "333333333333333";
return;
}
$options = array(
\OSS\OssClient::OSS_MAX_KEYS => 200,
\OSS\OssClient::OSS_PREFIX => $path,
);
try {
$listObjectInfo = $ossClient->listObjects($oss['BUCKET'], $options);
} catch (\OSS\Core\OssException $e) {
printf(__FUNCTION__ . ": FAILED\n");
printf($e->getMessage() . "\n");
return;
}
/**
* @param \OSS\Model\ObjectListInfo $listObjectInfo
* @param $ossClient
* @param $oss
*/
function extracted(\OSS\Model\ObjectListInfo $listObjectInfo,$ossClient,$oss):void
{
$prefixList = $listObjectInfo->getPrefixList();
// commonPrefixs The list shows fun All subfolders under the directory .
if (!empty($prefixList)) {
foreach ($prefixList as $prefixInfo) {
$options = array(
\OSS\OssClient::OSS_MAX_KEYS => 200,
\OSS\OssClient::OSS_PREFIX => $prefixInfo->getPrefix(),
);
$listSubjectObjectInfo = $ossClient->listObjects($oss['BUCKET'], $options);
extracted($listSubjectObjectInfo,$ossClient,$oss);
}
}
$objectList = $listObjectInfo->getObjectList();
$data=[];
if (!empty($objectList)) {
foreach ($objectList as $objectInfo) {
$data[] = $objectInfo->getKey();
}
$delObjects = $ossClient->deleteObjects($oss['BUCKET'], $data);
foreach ($delObjects as $info){
$obj = strval($info);
}
}
}
extracted($listObjectInfo,$ossClient,$oss);
return 'ok';边栏推荐
- How to get 5L water in a full 10L container, 7L or 4L empty container
- Siamrpn: recommended regional network and twin network
- Is the MySQL index tree built before each search or when the index is built?
- 【1.2.投资的收益和风险】
- Unity learning notes – infinite map
- postman 环境变量设置代码存放
- Matlab solution of [analysis of variance]
- NLP之NER:商品标题属性识别探索与实践
- Difference between filter and interceptor
- 【方差分析】之matlab求解
猜你喜欢

自编码器 AE(AutoEncoder)程序

Pokemon card evolution jsjs special effect

Siamfc: full convolution twin network for target tracking

Seata deployment and microservice integration

WPF 常用功能整合

领导抢功劳,我改个变量名让他下岗了

【1.2.投资的收益和风险】

Transc knowledge representation model

31. Opinion-based Relational Pivoting forCross-domain Aspect Term Extraction 阅读笔记

基于物联网的环境调节系统(ESP32-C3+Onenet+微信小程序)
随机推荐
Wechat applet - "do you really understand the use of applet components?
C# NanUI 相关功能整合
Flask send_ Absolute path traversal caused by file function
Unity learning notes – infinite map
Sqldeveloper tools quick start
【1.2.投资的收益和风险】
sp导出贴图到maya
VP视频结构化框架
Next generation visual transformer: Unlocking the correct combination of CNN and transformer
填问卷,领奖品 | 诚邀您填写 Google Play Academy 活动调研问卷
JMeter distributed
Simple implementation of pytorch
Siamfc: full convolution twin network for target tracking
Selenium code storage
JS analog clock with text label
Leetcode659. split the array into continuous subsequences (hash table)
Figure introduction to neural network core dataset
What is the transport layer protocol tcp/udp???
Postman environment variable setting code storage
次轮Okaleido Tiger即将登录Binance NFT,引发社区热议