Java Code Examples for com.aliyun.oss.model.ListObjectsRequest#setMarker()

The following examples show how to use com.aliyun.oss.model.ListObjectsRequest#setMarker() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OSSUtils.java    From xnx3 with Apache License 2.0 6 votes vote down vote up
/**
 * 查看某个路径下的文件所占用的资源的大小
 * @param filePath 要查看文件的路径,如 file/image/
 * @return 单位:B
 */
public long getFolderSize(String filePath){
	ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);
	listObjectsRequest.setPrefix(filePath); 
	listObjectsRequest.setMaxKeys(1000);
	
	boolean have = true;		//是否有下一页
	String nextMarker = null;
	int size = 0;		//总字节大小,单位:B
	while(have){
		if(nextMarker != null){
			listObjectsRequest.setMarker(nextMarker);
		}
		ObjectListing listO = getOSSClient().listObjects(listObjectsRequest);
		
	    for (OSSObjectSummary objectSummary : listO.getObjectSummaries()) {
	        size += objectSummary.getSize();  
	    }
	    
	    have = listO.isTruncated();
	    nextMarker = listO.getNextMarker();
	}
	return size;
}
 
Example 2
Source File: OSSUtils.java    From xnx3 with Apache License 2.0 6 votes vote down vote up
/**
 * 获取 指定目录下的所有文件对象
 * @param filePath 要查看文件的路径,如 file/image/
 * @return {@link List}
 */
public List<OSSObjectSummary> getFolderObjectList(String filePath){
	ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);
	listObjectsRequest.setPrefix(filePath); 
	listObjectsRequest.setMaxKeys(1000);
	List<OSSObjectSummary> list = new ArrayList<OSSObjectSummary>();
	
	boolean have = true;		//是否有下一页
	String nextMarker = null;
	while(have){
		if(nextMarker != null){
			listObjectsRequest.setMarker(nextMarker);
		}
		ObjectListing listO = getOSSClient().listObjects(listObjectsRequest);
		
	    for (OSSObjectSummary objectSummary : listO.getObjectSummaries()) {
	    	list.add(objectSummary);
	    }
	    
	    have = listO.isTruncated();
	    nextMarker = listO.getNextMarker();
	}
	return list;
}
 
Example 3
Source File: OSSUtil.java    From xnx3 with Apache License 2.0 6 votes vote down vote up
/**
 * 查看某个路径下的文件所占用的资源的大小
 * @param filePath 要查看文件的路径,如 file/image/
 * @return 单位:B
 */
public static long getFolderSize(String filePath){
	ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);
	listObjectsRequest.setPrefix(filePath); 
	listObjectsRequest.setMaxKeys(1000);
	
	boolean have = true;		//是否有下一页
	String nextMarker = null;
	int size = 0;		//总字节大小,单位:B
	while(have){
		if(nextMarker != null){
			listObjectsRequest.setMarker(nextMarker);
		}
		ObjectListing listO = OSSUtil.getOSSClient().listObjects(listObjectsRequest);
		
	    for (OSSObjectSummary objectSummary : listO.getObjectSummaries()) {
	        size += objectSummary.getSize();  
	    }
	    
	    have = listO.isTruncated();
	    nextMarker = listO.getNextMarker();
	}
	return size;
}
 
Example 4
Source File: OSSUtil.java    From xnx3 with Apache License 2.0 6 votes vote down vote up
/**
 * 获取 指定目录下的所有文件对象
 * @param filePath 要查看文件的路径,如 file/image/
 * @return {@link List}
 */
public static List<OSSObjectSummary> getFolderObjectList(String filePath){
	ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);
	listObjectsRequest.setPrefix(filePath); 
	listObjectsRequest.setMaxKeys(1000);
	List<OSSObjectSummary> list = new ArrayList<OSSObjectSummary>();
	
	boolean have = true;		//是否有下一页
	String nextMarker = null;
	while(have){
		if(nextMarker != null){
			listObjectsRequest.setMarker(nextMarker);
		}
		ObjectListing listO = OSSUtil.getOSSClient().listObjects(listObjectsRequest);
		
	    for (OSSObjectSummary objectSummary : listO.getObjectSummaries()) {
	    	list.add(objectSummary);
	    }
	    
	    have = listO.isTruncated();
	    nextMarker = listO.getNextMarker();
	}
	return list;
}
 
Example 5
Source File: AliOSSBlobStore.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
private ListObjectsRequest toListObjectRequest(String container, ListContainerOptions options) {
    ListObjectsRequest request = new ListObjectsRequest(container);
    if (options.getMaxResults() != null) {
        request.setMaxKeys(options.getMaxResults());
    }
    if (options.getMarker() != null) {
        request.setMarker(options.getMarker());
    }
    return request;
}