• oss分页列举遍历文件创建软链接


    	/**
    	 * // Endpoint以杭州为例,其它Region请按实际情况填写。
    String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
    // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录RAM控制台创建RAM账号。
    String accessKeyId = "<yourAccessKeyId>";
    String accessKeySecret = "<yourAccessKeySecret>";
    String bucketName = "<yourBucketName>";
    
    // 创建OSSClient实例。
    OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    
    final int maxKeys = 200;
    String nextMarker = null;
    ObjectListing objectListing;
    
    do {
        objectListing = ossClient.listObjects(new ListObjectsRequest(bucketName).withMarker(nextMarker).withMaxKeys(maxKeys));
    
        List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
        for (OSSObjectSummary s : sums) {
            System.out.println("	" + s.getKey());
        }
    
        nextMarker = objectListing.getNextMarker();
    
    } while (objectListing.isTruncated());
    
    // 关闭OSSClient。
    ossClient.shutdown();
                        
    	 */
    
    参考网址:https://help.aliyun.com/document_detail/84841.html?spm=5176.11065259.1996646101.searchclickresult.7e1a7b57qlFzAR
    	
    

     

    示例代码:
    
    private void GetFileAllContentPA(String str) {
    		OSS ossClient = new OSSClientBuilder().build(endPoint, accessKey, accessSecret);
    		final int maxKeys = 200;
    		String nextMarker = null;
    		ObjectListing objectListing;
    		do {
    			objectListing = ossClient.listObjects(
    					new ListObjectsRequest(bucketName).withPrefix(str).withMarker(nextMarker).withMaxKeys(maxKeys));
    			List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
    			for (OSSObjectSummary s : sums) {
    				boolean flag = Pattern.matches(CommonConstant.REGEX, (s.getKey().split(CommonConstant.PATH_SYMBOL)[CommonConstant.FILE_PATH_INDEX]));
    				if (!flag) {
    					if (s.getKey().endsWith(CommonConstant.TRANS_NO_PDF)) {
    						String trans = s.getKey().substring(s.getKey().lastIndexOf(CommonConstant.PATH_SYMBOL) + 1);
    						log.info("============" + s.getKey());
    						ossUtils.CreateConnection(trans.substring(CommonConstant.TRANS_NO_INDEX, CommonConstant.TRANS_NO_LONG), s.getKey());
    						ReceiptRecord receiptRecord =new ReceiptRecord(); 
    				    	receiptRecord.setTransNo(trans.substring(CommonConstant.TRANS_NO_INDEX, CommonConstant.TRANS_NO_LONG));
    				    	receiptRecord.setFilePath( s.getKey());
    				    	receiptRecord.setCreateDate(new Date());;
    				    	pingAnService.insertRecord(receiptRecord);
    					}
    				}
    
    			}
    			nextMarker = objectListing.getNextMarker();
    
    		} while (objectListing.isTruncated());
    
    		// 关闭OSSClient。
    		ossClient.shutdown();
    
    	}
    

      

     

    人这辈子没法做太多事情,所以每做一件事都要做到精彩绝伦。 因为,这就是我的宿命。人生苦短,你明白吗? 所以这是我为人生做出的选择
  • 相关阅读:
    解决IE6不支持position:fixed的bug
    响应式Web设计基础
    多行文本溢出显示省略号(…)全攻略
    解读CSS布局之-水平垂直居
    理解CSS中BFC
    七个你可能不了解的CSS单位
    屏蔽系统热键钩子Hook程序
    Win 2008 r2 远程桌面多用户登陆,一用户多登陆配置
    把Excel转换成DataTable,Excel2003+
    DataGridView不显示未绑定的列-AutoGenerateColumns
  • 原文地址:https://www.cnblogs.com/junjun1578/p/13984885.html
Copyright © 2020-2023  润新知