• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java GetObjectRequest类的典型用法和代码示例

java 2次浏览

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

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

示例1: reopen

点赞 2

import com.aliyun.oss.model.GetObjectRequest; //导入依赖的package包/类
private synchronized void reopen(long pos) throws IOException {

    if (inputStream != null) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Aborting old stream " + "to open at pos " + pos);
      }
      inputStream.close();
    }

    if (pos < 0) {
      throw new EOFException(FSExceptionMessages.NEGATIVE_SEEK + " " + pos);
    }

    if (contentLength > 0 && pos > contentLength - 1) {
      throw new EOFException(
              FSExceptionMessages.CANNOT_SEEK_PAST_EOF + " " + pos);
    }

    LOG.debug("Actually opening file " + key + " at pos " + pos);

    GetObjectRequest request = new GetObjectRequest(bucket, key);
    request.setRange(pos, contentLength - 1);

    inputStream = ossClient.getObject(request).getObjectContent();

    if (inputStream == null) {
      throw new IOException("Null IO stream");
    }

    this.pos = pos;
  }
 

开发者ID:aliyun-beta,
项目名称:aliyun-oss-hadoop-fs,
代码行数:32,
代码来源:OSSInputStream.java

示例2: testMultiPartCopyUpload

点赞 2

import com.aliyun.oss.model.GetObjectRequest; //导入依赖的package包/类
/**
 * Test high performance copy and upload.
 *
 * @throws Exception
 */
public void testMultiPartCopyUpload() throws Exception {
  final File sampleFile = createSampleFile(1100000); //48.83 MB
  long fileLength = sampleFile.length();

  PutObjectRequest putObjectRequest = new PutObjectRequest("hadoop-intg", fileSystem.getWorkingDirectory() + "/test-multipart-upload", sampleFile);
  client.putObject(putObjectRequest);
  String originMD5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(new FileInputStream(sampleFile));
  System.out.println("[uploadMd5] " + originMD5);

  File uploadedFile = new File("/tmp/test-multipart-upload");
  uploadedFile.deleteOnExit();
  client.getObject(new GetObjectRequest("hadoop-intg", fileSystem.getWorkingDirectory() + "/test-multipart-upload"), uploadedFile);
  String uploadMD5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(new FileInputStream(uploadedFile));
  System.out.println("[downloadMd5] " + uploadMD5);
  assertEquals(originMD5, uploadMD5);


  CopyObjectRequest copyObjectRequest = new CopyObjectRequest("hadoop-intg", fileSystem.getWorkingDirectory() + "/test-multipart-upload",
          "hadoop-intg", "test-multipart-copy");
  client.copyObject(copyObjectRequest);

  File copiedFile = new File("/tmp/test-multipart-copy");
  copiedFile.deleteOnExit();
  client.getObject(new GetObjectRequest("hadoop-intg", "test-multipart-copy"), copiedFile);
  String copiedMD5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(new FileInputStream(copiedFile));
  System.out.println("[copiedMd5] " + copiedMD5);
  assertEquals(originMD5, copiedMD5);
}
 

开发者ID:aliyun-beta,
项目名称:aliyun-oss-hadoop-fs,
代码行数:34,
代码来源:ExtraOSSAPIsTest.java

示例3: getBlob

点赞 2

import com.aliyun.oss.model.GetObjectRequest; //导入依赖的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

示例4: downloadFile

点赞 2

import com.aliyun.oss.model.GetObjectRequest; //导入依赖的package包/类
public static void downloadFile(String key, String filename) throws OSSException, ClientException {
	if (client == null) throw new OSSException("OssKit must init before use");

	client.getObject(new GetObjectRequest(buketName, key), new File(filename));
}
 

开发者ID:jayqqaa12,
项目名称:jbase,
代码行数:6,
代码来源:OSSKit.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)