腾讯云 对象存储 文件列表
作者:互联网
$cosClient = new Client(array(
'region' => env('Q_CLOUD.region'),
'schema' => 'http',
'credentials' => array(
'secretId' => env('Q_CLOUD.SECRETID'),
'secretKey' => env('Q_CLOUD.SECRETKEY'),
)
));
$result = $cosClient->listObjects(array(
'Bucket' => env('q_cloud.bucket'),
'Prefix' => 'hipc/test/',
'MaxKeys' => 10,
));
if (isset($result['Contents'])) {
foreach ($result['Contents'] as $rt) {
// 打印key
echo($rt['Key'] . "\n");
}
}
结果
hipc/test/62d50316c395f1658127126.png
hipc/test/62d50321a7c121658127137.png
hipc/test/62d50424a9b681658127396.png
hipc/test/62d504258a52f1658127397.png
hipc/test/62d50874b18a71658128500.png
hipc/test/62d50882e14bb1658128514.png
最新上传的文件排最后
Prefix 是路径
MaxKeys 查询数量
不支持按时间排序
标签:存储,hipc,列表,result,env,腾讯,test,array,png 来源: https://www.cnblogs.com/xuyaoxiang1991/p/16490578.html