当前位置: 首页>>代码示例>>Java>>正文


Java OSSObjectSummary类代码示例

本文整理汇总了Java中com.aliyun.oss.model.OSSObjectSummary的典型用法代码示例。如果您正苦于以下问题:Java OSSObjectSummary类的具体用法?Java OSSObjectSummary怎么用?Java OSSObjectSummary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OSSObjectSummary类属于com.aliyun.oss.model包,在下文中一共展示了OSSObjectSummary类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFolderSize

import com.aliyun.oss.model.OSSObjectSummary; //导入依赖的package包/类
/**
 * 查看某个路径下的文件所占用的资源的大小
 * @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;
}
 
开发者ID:xnx3,项目名称:xnx3,代码行数:29,代码来源:OSSUtils.java

示例2: getFolderObjectList

import com.aliyun.oss.model.OSSObjectSummary; //导入依赖的package包/类
/**
 * 获取 指定目录下的所有文件对象
 * @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;
}
 
开发者ID:xnx3,项目名称:xnx3,代码行数:29,代码来源:OSSUtils.java

示例3: getFolderSize

import com.aliyun.oss.model.OSSObjectSummary; //导入依赖的package包/类
/**
 * 查看某个路径下的文件所占用的资源的大小
 * @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;
}
 
开发者ID:xnx3,项目名称:xnx3,代码行数:29,代码来源:OSSUtil.java

示例4: getFolderObjectList

import com.aliyun.oss.model.OSSObjectSummary; //导入依赖的package包/类
/**
 * 获取 指定目录下的所有文件对象
 * @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;
}
 
开发者ID:xnx3,项目名称:xnx3,代码行数:29,代码来源:OSSUtil.java

示例5: parseToCCSObjectSummary

import com.aliyun.oss.model.OSSObjectSummary; //导入依赖的package包/类
/**
 * OSSObjectSummary到CCSObjectSummary
 */
public static CCSObjectSummary parseToCCSObjectSummary(OSSObjectSummary ossObjectSummary) {
	CCSObjectSummary ccsObjectSummary = new CCSObjectSummary();
	ccsObjectSummary.setCCSOwner(parseToCCSOwner(ossObjectSummary.getOwner()));
	ccsObjectSummary.setBucketName(ossObjectSummary.getBucketName());
	ccsObjectSummary.setCcsPath(ossObjectSummary.getKey());
	ccsObjectSummary.setETag(ossObjectSummary.getETag());
	ccsObjectSummary.setLastModified(ossObjectSummary.getLastModified());
	ccsObjectSummary.setSize(ossObjectSummary.getSize());
	ccsObjectSummary.setStorgeClass(ossObjectSummary.getStorageClass());
	return ccsObjectSummary;
}
 
开发者ID:MinsxCloud,项目名称:minsx-ccs,代码行数:15,代码来源:AliyunOSSParseUtil.java

示例6: listAllObjects

import com.aliyun.oss.model.OSSObjectSummary; //导入依赖的package包/类
@Test
public void listAllObjects() {
	final int maxKeys = 200;
	String nextMarker = null;
	ObjectListing objectListing=null;
	do {
	    objectListing = ossClient.listObjects(new ListObjectsRequest("minsx-bucket").withMarker(nextMarker).withMaxKeys(maxKeys));
	    List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
	    for (OSSObjectSummary s : sums) {
	        System.out.println("\t" + s.getKey());
	    }
	    nextMarker = objectListing.getNextMarker();
	} while (objectListing.isTruncated());
}
 
开发者ID:MinsxCloud,项目名称:minsx-ccs,代码行数:15,代码来源:OSSTest.java

示例7: getObjectList

import com.aliyun.oss.model.OSSObjectSummary; //导入依赖的package包/类
public static List<OSSObjectSummary> getObjectList(String bucketName,
		String prefix, int endIndex, int maxKeys) {
	// 初始化OSSClient
	OSSClient client = getOSSClient();

	// 构造ListObjectsRequest请求
	ListObjectsRequest listObjectsRequest = new ListObjectsRequest(
			bucketName);

	// 递归列出fun目录下的所有文件
	listObjectsRequest.setPrefix(prefix);
	listObjectsRequest.setMaxKeys(maxKeys);
	// listObjectsRequest.setMarker("ueditor/jsp/upload/image/20150614/1434267568217077840.jpg");

	ObjectListing listing = null;
	String nextMarker = null;

	// endIndex>maxKeys
	int pageNum = endIndex / maxKeys;
	for (int i = 0; i < pageNum; i++) {
		if (nextMarker != null) {
			listObjectsRequest.setMarker(nextMarker);
		}
		listing = client.listObjects(listObjectsRequest);
		nextMarker = listing.getNextMarker();
	}

	// 遍历所有Object
	List<OSSObjectSummary> objectSummarys = listing.getObjectSummaries();

	return objectSummarys;
	// 遍历所有CommonPrefix
	/*
	 * System.out.println("\nCommonPrefixs:"); for (String commonPrefix :
	 * listing.getCommonPrefixes()) { System.out.println(commonPrefix); }
	 */
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:38,代码来源:AliyunOSS.java

示例8: main

import com.aliyun.oss.model.OSSObjectSummary; //导入依赖的package包/类
public static void main(String[] args) {

		List<OSSObjectSummary> objectSummaries = AliyunOSS.getObjectList(
				DiaowenProperty.UPLOADFILE_BACKET, "ueditor/jsp/upload/image/", 4, 2);
		System.out.println(objectSummaries.size());
		for (OSSObjectSummary ossObjectSummary : objectSummaries) {
			System.out.println(ossObjectSummary.getKey() + ":"
					+ ossObjectSummary.getSize());
		}
	}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:11,代码来源:AliyunOSS.java

示例9: listObject

import com.aliyun.oss.model.OSSObjectSummary; //导入依赖的package包/类
/**
 * 列出Object<br>
 *
 * @param client
 * @param bucketName
 * @param delimiter  Delimiter 设置为 “/” 时,返回值就只罗列该文件夹下的文件,可以null
 * @param prefix     Prefix 设为某个文件夹名,就可以罗列以此 Prefix 开头的文件,可以null
 * @return
 */
public static List<String> listObject(OSSClient client, String bucketName, String delimiter, String prefix) {

	// 是否循环的标识
	boolean hasNext = false;
	// 设定结果从Marker之后按字母排序的第一个开始返回
	String marker = "";
	//
	// ObjectListing listing = new ObjectListing();
	List<String> filePathList = new ArrayList<String>();
	// 构造ListObjectsRequest请求
	ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);

	// 是一个用于对Object名字进行分组的字符。所有名字包含指定的前缀且第一次出现Delimiter字符之间的object作为一组元素:
	// CommonPrefixes
	listObjectsRequest.setDelimiter(delimiter);
	// 限定此次返回object的最大数,如果不设定,默认为100,MaxKeys取值不能大于1000
	listObjectsRequest.setMaxKeys(20);
	// 限定返回的object key必须以Prefix作为前缀。注意使用prefix查询时,返回的key中仍会包含Prefix
	listObjectsRequest.setPrefix(prefix);

	do {
		// 设定结果从Marker之后按字母排序的第一个开始返回
		listObjectsRequest.setMarker(marker);
		// 获取指定bucket下的所有Object信息
		ObjectListing sublisting = client.listObjects(listObjectsRequest);
		// 如果Bucket中的Object数量大于100,则只会返回100个Object, 且返回结果中 IsTruncated
		// 为false
		if (sublisting.isTruncated()) {
			hasNext = true;
			marker = sublisting.getNextMarker();
		} else {
			hasNext = false;
			marker = "";
		}
		// // 遍历所有Object
		for (OSSObjectSummary objectSummary : sublisting.getObjectSummaries()) {
			// System.out.println(objectSummary.getKey());
			filePathList.add(objectSummary.getKey());
		}
	} while (hasNext);

	return filePathList;
}
 
开发者ID:funtl,项目名称:framework,代码行数:53,代码来源:ObjectService.java

示例10: list

import com.aliyun.oss.model.OSSObjectSummary; //导入依赖的package包/类
@Override
public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
   OSS oss = api.getOSSClient(OSSApi.DEFAULT_REGION);
   String region = oss.getBucketLocation(container);
   final OSS foss = api.getOSSClient(region);
   final Location location = new LocationBuilder()
         .id(region)
         .scope(LocationScope.REGION)
         .description(region)
         .build();
   ListObjectsRequest req = new ListObjectsRequest(container);
   if (options.getDir() != null) {
      req.setPrefix(options.getDir());
   }
   if (options.getMaxResults() != null) {
      req.setMaxKeys(options.getMaxResults());
   }
   if (options.getMarker() != null) {
      req.setMarker(options.getMarker());
   }
   ObjectListing listing = foss.listObjects(req);
   PageSetImpl<StorageMetadata> pageSet = new PageSetImpl<StorageMetadata>(
         transform(listing.getObjectSummaries(), new Function<OSSObjectSummary, StorageMetadata>() {
               @Override
               public StorageMetadata apply(OSSObjectSummary input) {
                  URI uri = null;
                  StorageType storagetType = StorageType.BLOB;
                  if (input.getKey().endsWith("/")) {
                     storagetType = StorageType.FOLDER;
                  } else {
                     Calendar time = Calendar.getInstance();
                     time.set(Calendar.HOUR, time.get(Calendar.HOUR) + 1);
                     Date expires = time.getTime();
                     URL url = foss.generatePresignedUrl(input.getBucketName(), input.getKey(), expires);
                     try {
                        uri = url.toURI();
                     } catch (URISyntaxException e) {
                        logger.warn(e.getMessage());
                     }
                  }
                  StorageMetadata storageMetadata = new StorageMetadataImpl(
                        storagetType,
                        input.getKey(),
                        input.getKey(),
                        location,
                        uri,
                        input.getETag(),
                        input.getLastModified(),
                        input.getLastModified(),
                        ImmutableMap.<String, String>builder().build(),
                        input.getSize());
                  return storageMetadata;
               }
            }), listing.getNextMarker());
   return pageSet;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:57,代码来源:OSSBlobStore.java


注:本文中的com.aliyun.oss.model.OSSObjectSummary类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。