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


Java OSSObject类代码示例

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


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

示例1: download1

import com.aliyun.oss.model.OSSObject; //导入依赖的package包/类
@GetMapping("/aliyun/download1")
public String download1() throws IOException {
    StringBuffer result = new StringBuffer();
    OSSObject ossObject = aliyunOssClient.getObject(OssConstant.ALIYUN_OSS_BUCKET_NAME, "text.txt");
    InputStream content = ossObject.getObjectContent();
    if (content != null) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
        while (true) {
            String line = reader.readLine();
            if (line == null) break;
            result.append("\n" + line);
        }
        content.close();
    }
    return result.toString();
}
 
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:17,代码来源:DemoController.java

示例2: download1

import com.aliyun.oss.model.OSSObject; //导入依赖的package包/类
@GetMapping("/aliyun/download1")
public String download1() throws IOException {
    StringBuffer result = new StringBuffer();
    OSSObject ossObject = aliyunOssClient.getObject(OssConstant.ALIYUN_OSS_BUCKET_NAME, "text.txt");
    InputStream content = ossObject.getObjectContent();
    if (content != null) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
        while (true) {
            String line = reader.readLine();
            if (line == null) {
                break;
            }
            result.append("\n" + line);
        }
        content.close();
    }
    return result.toString();
}
 
开发者ID:ChangyiHuang,项目名称:shuzheng,代码行数:19,代码来源:DemoController.java

示例3: test

import com.aliyun.oss.model.OSSObject; //导入依赖的package包/类
@Test
public void test() throws OSSException, ClientException, IOException {
    OSSClient client = new OSSClient("oss-cn-hangzhou.aliyuncs.com", "", "", "");
    // BucketInfo info = client.getBucketInfo("edrmry");
    boolean exists = client.doesBucketExist("edrmry");
    System.out.println(exists);
    // System.out.println(client.listBuckets().size());
    // client.createBucket("dzh1");
    PutObjectResult r = client.putObject("edrmry", "dzh1.jpg", new FileInputStream("/Users/dzh/Pictures/8.pic.jpg"));
    System.out.println(r.getETag());
    OSSObject o = client.getObject("edrmry", "dzh1");
    InputStream is = o.getObjectContent();

    FileOutputStream fos = new FileOutputStream("/Users/dzh/Pictures/8.pic.2.jpg");
    int len = 0;
    byte[] buf = new byte[32];
    while ((len = is.read(buf)) != -1) {
        fos.write(buf, 0, len);
    }
    fos.flush();
    fos.close();
}
 
开发者ID:dzh,项目名称:jframe,代码行数:23,代码来源:TestOSSService.java

示例4: parseToCCSObject

import com.aliyun.oss.model.OSSObject; //导入依赖的package包/类
/**
 * OSSObject到CCSObject
 */
public static CCSObject parseToCCSObject(OSSObject ossObject) {
	CCSObject ccsObject = new CCSObject();
	ccsObject.setBucketName(ossObject.getBucketName());
	ccsObject.setCcsPath(ossObject.getKey());
	ccsObject.setObjectContent(ossObject.getObjectContent());
	ccsObject.setCcsObjectMetadata(parseToCCSObjectMetadata(ossObject.getObjectMetadata()));
	return ccsObject;
}
 
开发者ID:MinsxCloud,项目名称:minsx-ccs,代码行数:12,代码来源:AliyunOSSParseUtil.java

示例5: getObject

import com.aliyun.oss.model.OSSObject; //导入依赖的package包/类
public static InputStream getObject(String bucketName, String fileName) {
	// 初始化OSSClient
	OSSClient client = getOSSClient();

	// client.getObject(new GetObjectRequest(bucketName, key),new
	// File(filename));
	OSSObject ossObject = client.getObject(bucketName, fileName);
	InputStream inputStream = ossObject.getObjectContent();

	return inputStream;
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:12,代码来源:AliyunOSS.java

示例6: getBlob

import com.aliyun.oss.model.OSSObject; //导入依赖的package包/类
@Override
public Blob getBlob(String container, String name, GetOptions options) {
   OSS oss = api.getOSSClient(OSSApi.DEFAULT_REGION);
   String region = oss.getBucketLocation(container);
   oss = api.getOSSClient(region);
   GetObjectRequest req = new GetObjectRequest(container, name);
   OSSObject object = oss.getObject(req);
   String filename = object.getKey();
   return blobBuilder(container)
         .name(filename)
         .payload(object.getObjectContent())
         .build();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:14,代码来源:OSSBlobStore.java

示例7: get

import com.aliyun.oss.model.OSSObject; //导入依赖的package包/类
public InputStream get(@Nonnull String bucketName, @Nonnull String folder, @Nonnull String name) {
    checkNotNull(bucketName);
    checkNotNull(folder);
    checkNotNull(name);

    String key = formatKey(folder, name);

    OSSObject object = ossClient.getObject(bucketName, key);

    return object.getObjectContent();
}
 
开发者ID:srarcbrsent,项目名称:tc,代码行数:12,代码来源:TcAliyunOssService.java

示例8: getOSSObject

import com.aliyun.oss.model.OSSObject; //导入依赖的package包/类
public Optional<OSSObject> getOSSObject(){
	if(ossObject!=null){
		return ossObject;
	}
	if(!ossClient.doesObjectExist(bucketName, key)){
		ossObject = Optional.empty();
	}else{
		ossObject = Optional.ofNullable(ossClient.getObject(bucketName, key));
	}
	return ossObject;
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:12,代码来源:OssClientWrapper.java

示例9: override

import com.aliyun.oss.model.OSSObject; //导入依赖的package包/类
public ObjectOperation override(File file){
	Optional<OSSObject> opt = getOSSObject();
	if(!opt.isPresent()){
		throw new BaseException("key["+key+"] is not exists in bucket["+bucketName+"]");
	}
	return store(file);
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:8,代码来源:OssClientWrapper.java

示例10: blobMetadata

import com.aliyun.oss.model.OSSObject; //导入依赖的package包/类
@Override
public BlobMetadata blobMetadata(String container, String name) {
   OSS oss = api.getOSSClient(OSSApi.DEFAULT_REGION);
   String region = oss.getBucketLocation(container);
   oss = api.getOSSClient(region);
   OSSObject object = oss.getObject(container, name);
   Calendar time = Calendar.getInstance();
   time.set(Calendar.HOUR, time.get(Calendar.HOUR) + 1);
   Date expires = time.getTime();
   URL url = oss.generatePresignedUrl(container, name, expires);
   URI uri = null;
   try {
      uri = url.toURI();
   } catch (URISyntaxException e) {
      logger.warn(e, e.getMessage());
   }
   Location location = new LocationBuilder()
         .id(region)
         .scope(LocationScope.REGION)
         .description(region)
         .build();
   ContentMetadata cm = ContentMetadataBuilder.create()
         .expires(expires)
         .contentDisposition(object.getObjectMetadata().getContentDisposition())
         .contentEncoding(object.getObjectMetadata().getContentEncoding())
         .contentLength(object.getObjectMetadata().getContentLength())
         .contentType(object.getObjectMetadata().getContentType())
         .build();
   return new BlobMetadataImpl(
         object.getKey(),
         object.getKey(),
         location,
         uri,
         object.getObjectMetadata().getETag(),
         object.getObjectMetadata().getLastModified(),
         object.getObjectMetadata().getLastModified(),
         object.getObjectMetadata().getUserMetadata(),
         uri,
         object.getBucketName(),
         cm);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:42,代码来源:OSSBlobStore.java

示例11: getObject

import com.aliyun.oss.model.OSSObject; //导入依赖的package包/类
public static void getObject(OSSClient client, String bucketName, String key) throws IOException {

		// 获取Object,返回结果为OSSObject对象
		OSSObject object = client.getObject(bucketName, key);

		// 获取Object的输入流
		InputStream objectContent = object.getObjectContent();

		// 处理Object

		// 关闭流
		objectContent.close();

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


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