您的位置:首页 > 游戏 > 手游 > 创业it外包公司_人工智能网站建设_如何设计一个网站页面_帮别人推广app赚钱

创业it外包公司_人工智能网站建设_如何设计一个网站页面_帮别人推广app赚钱

2025/4/3 14:15:06 来源:https://blog.csdn.net/weixin_62108279/article/details/146328580  浏览:    关键词:创业it外包公司_人工智能网站建设_如何设计一个网站页面_帮别人推广app赚钱
创业it外包公司_人工智能网站建设_如何设计一个网站页面_帮别人推广app赚钱

1,引入依赖

<dependency><groupId>com.aliyun.oss</groupId><artifactId>aliyun-sdk-oss</artifactId><version>3.16.1</version>
</dependency>

2,方法

/*** 删除指定前缀或目录下的多个文件** @param prefix 删除目录*/public void deletePathFileList(String prefix) {OSS ossClient = null;try {//封装创建Oss实例CredentialsProvider credentialsProvider = new DefaultCredentialProvider(access_key, secret_key);ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);ossClient = OSSClientBuilder.create().endpoint(endpoint).credentialsProvider(credentialsProvider).clientConfiguration(clientBuilderConfiguration).region(region).build();// 列举所有包含指定前缀的文件并删除。String nextMarker = null;ObjectListing objectListing;do {ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucket).withPrefix(prefix).withMarker(nextMarker);objectListing = ossClient.listObjects(listObjectsRequest);if (!objectListing.getObjectSummaries().isEmpty()) {List<String> keys = new ArrayList<>();for (OSSObjectSummary s : objectListing.getObjectSummaries()) {keys.add(s.getKey());}DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucket).withKeys(keys).withEncodingType("url");DeleteObjectsResult deleteObjectsResult = ossClient.deleteObjects(deleteObjectsRequest);List<String> deletedObjects = deleteObjectsResult.getDeletedObjects();for (String obj : deletedObjects) {String deleteObj = URLDecoder.decode(obj, "UTF-8");System.out.println(deleteObj);}}nextMarker = objectListing.getNextMarker();} while (objectListing.isTruncated());} catch (Exception e) {log.error("阿里云删除指定前缀或目录下的多个文件异常:{}", e.getMessage());} finally {if (ossClient != null) {ossClient.shutdown();}}}

 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com