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


Java S3Object类代码示例

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


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

示例1: write

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
@Override
public HttpResponseOutputStream<List<MultipartPart>> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    final S3Object object = new S3WriteFeature(session, new S3DisabledMultipartService())
        .getDetails(file, status);
    // ID for the initiated multipart upload.
    final MultipartUpload multipart;
    try {
        multipart = session.getClient().multipartStartUpload(
            containerService.getContainer(file).getName(), object);
        if(log.isDebugEnabled()) {
            log.debug(String.format("Multipart upload started for %s with ID %s",
                multipart.getObjectKey(), multipart.getUploadId()));
        }
    }
    catch(ServiceException e) {
        throw new S3ExceptionMappingService().map("Upload {0} failed", e, file);
    }
    final MultipartOutputStream proxy = new MultipartOutputStream(multipart, file, status);
    return new HttpResponseOutputStream<List<MultipartPart>>(new MemorySegementingOutputStream(proxy,
        preferences.getInteger("s3.upload.multipart.partsize.minimum"))) {
        @Override
        public List<MultipartPart> getStatus() throws BackgroundException {
            return proxy.getCompleted();
        }
    };
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:27,代码来源:S3MultipartWriteFeature.java

示例2: read

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
@Override
public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    try {
        final HttpRange range = HttpRange.withStatus(status);
        final RequestEntityRestStorageService client = session.getClient();
        final S3Object object = client.getVersionedObject(
                file.attributes().getVersionId(),
                containerService.getContainer(file).getName(),
                containerService.getKey(file),
                null, // ifModifiedSince
                null, // ifUnmodifiedSince
                null, // ifMatch
                null, // ifNoneMatch
                status.isAppend() ? range.getStart() : null,
                status.isAppend() ? (range.getEnd() == -1 ? null : range.getEnd()) : null);
        if(log.isDebugEnabled()) {
            log.debug(String.format("Reading stream with content length %d", object.getContentLength()));
        }
        return object.getDataInputStream();
    }
    catch(ServiceException e) {
        throw new S3ExceptionMappingService().map("Download {0} failed", e, file);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:25,代码来源:S3ReadFeature.java

示例3: getClass

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
@Override
public String getClass(final Path file) throws BackgroundException {
    if(file.isFile() || file.isPlaceholder()) {
        // HEAD request provides storage class information of the object.
        // S3 returns this header for all objects except for Standard storage class objects.
        final String redundancy = new S3AttributesFinderFeature(session).find(file).getStorageClass();
        if(StringUtils.isBlank(redundancy)) {
            return S3Object.STORAGE_CLASS_STANDARD;
        }
        return redundancy;
    }
    if(containerService.isContainer(file)) {
        final String key = String.format("s3.storageclass.%s", containerService.getContainer(file).getName());
        if(StringUtils.isNotBlank(preferences.getProperty(key))) {
            return preferences.getProperty(key);
        }
    }
    return S3Object.STORAGE_CLASS_STANDARD;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:20,代码来源:S3StorageClassFeature.java

示例4: testSetClassFile

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
@Test
public void testSetClassFile() throws Exception {
    final S3Session session = new S3Session(
            new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
                    new Credentials(
                            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
                    )));
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.volume));
    final Path test = new S3TouchFeature(session).touch(new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)), new TransferStatus());
    final S3StorageClassFeature feature = new S3StorageClassFeature(session);
    assertEquals(S3Object.STORAGE_CLASS_STANDARD, feature.getClass(test));
    feature.setClass(test, "STANDARD_IA");
    assertEquals("STANDARD_IA", feature.getClass(test));
    feature.setClass(test, S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY);
    assertEquals(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY, feature.getClass(test));
    assertEquals(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY, new S3AttributesFinderFeature(session).find(test).getStorageClass());
    new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:22,代码来源:S3StorageClassFeatureTest.java

示例5: testSetClassPlaceholder

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
@Test
public void testSetClassPlaceholder() throws Exception {
    final S3Session session = new S3Session(
            new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
                    new Credentials(
                            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
                    )));
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.volume));
    final Path test = new S3DirectoryFeature(session, new S3WriteFeature(session, new S3DisabledMultipartService())).mkdir(
            new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)), null, new TransferStatus());
    final S3StorageClassFeature feature = new S3StorageClassFeature(session);
    assertEquals(S3Object.STORAGE_CLASS_STANDARD, feature.getClass(test));
    feature.setClass(test, "STANDARD_IA");
    assertEquals("STANDARD_IA", feature.getClass(test));
    feature.setClass(test, S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY);
    assertEquals(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY, feature.getClass(test));
    new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:22,代码来源:S3StorageClassFeatureTest.java

示例6: lifecyclePopupClicked

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
@Action
public void lifecyclePopupClicked(final NSButton sender) {
    if(this.toggleS3Settings(false)) {
        final LifecycleConfiguration configuration = new LifecycleConfiguration(
            lifecycleTransitionCheckbox.state() == NSCell.NSOnState ? Integer.valueOf(lifecycleTransitionPopup.selectedItem().representedObject()) : null,
            S3Object.STORAGE_CLASS_GLACIER,
            lifecycleDeleteCheckbox.state() == NSCell.NSOnState ? Integer.valueOf(lifecycleDeletePopup.selectedItem().representedObject()) : null);
        controller.background(new WorkerBackgroundAction<Boolean>(controller, session, new WriteLifecycleWorker(files, configuration) {
            @Override
            public void cleanup(final Boolean result) {
                toggleS3Settings(true);
                initS3();
            }
        }));
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:17,代码来源:InfoController.java

示例7: storeLargeFile

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
public void storeLargeFile(String key, File file, byte[] md5Hash)
    throws IOException {
  S3Object object = new S3Object(key);
  object.setDataInputFile(file);
  object.setContentType("binary/octet-stream");
  object.setContentLength(file.length());
  object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm);
  if (md5Hash != null) {
    object.setMd5Hash(md5Hash);
  }

  List<StorageObject> objectsToUploadAsMultipart =
      new ArrayList<StorageObject>();
  objectsToUploadAsMultipart.add(object);
  MultipartUtils mpUtils = new MultipartUtils(multipartBlockSize);

  try {
    mpUtils.uploadObjects(bucket.getName(), s3Service,
                          objectsToUploadAsMultipart, null);
  } catch (Exception e) {
    handleException(e, key);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:Jets3tNativeFileSystemStore.java

示例8: retrieve

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
/**
 *
 * @param key
 * The key is the object name that is being retrieved from the S3 bucket
 * @return
 * This method returns null if the key is not found
 * @throws IOException
 */

@Override
public InputStream retrieve(String key, long byteRangeStart)
        throws IOException {
  try {
    LOG.debug("Getting key: {} from bucket: {} with byteRangeStart: {}",
        key, bucket.getName(), byteRangeStart);
    S3Object object = s3Service.getObject(bucket, key, null, null, null,
                                          null, byteRangeStart, null);
    return object.getDataInputStream();
  } catch (ServiceException e) {
    handleException(e, key);
    return null;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:Jets3tNativeFileSystemStore.java

示例9: copy

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
@Override
public void copy(String srcKey, String dstKey) throws IOException {
  try {
    if(LOG.isDebugEnabled()) {
      LOG.debug("Copying srcKey: " + srcKey + "to dstKey: " + dstKey + "in bucket: " + bucket.getName());
    }
    if (multipartEnabled) {
      S3Object object = s3Service.getObjectDetails(bucket, srcKey, null,
                                                   null, null, null);
      if (multipartCopyBlockSize > 0 &&
          object.getContentLength() > multipartCopyBlockSize) {
        copyLargeFile(object, dstKey);
        return;
      }
    }

    S3Object dstObject = new S3Object(dstKey);
    dstObject.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm);
    s3Service.copyObject(bucket.getName(), srcKey, bucket.getName(),
        dstObject, false);
  } catch (ServiceException e) {
    handleException(e, srcKey);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:Jets3tNativeFileSystemStore.java

示例10: checkMetadata

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
private void checkMetadata(S3Object object) throws S3FileSystemException,
    S3ServiceException {
  
  String name = (String) object.getMetadata(FILE_SYSTEM_NAME);
  if (!FILE_SYSTEM_VALUE.equals(name)) {
    throw new S3FileSystemException("Not a Hadoop S3 file.");
  }
  String type = (String) object.getMetadata(FILE_SYSTEM_TYPE_NAME);
  if (!FILE_SYSTEM_TYPE_VALUE.equals(type)) {
    throw new S3FileSystemException("Not a block file.");
  }
  String dataVersion = (String) object.getMetadata(FILE_SYSTEM_VERSION_NAME);
  if (!FILE_SYSTEM_VERSION_VALUE.equals(dataVersion)) {
    throw new VersionMismatchException(FILE_SYSTEM_VERSION_VALUE,
        dataVersion);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:Jets3tFileSystemStore.java

示例11: listSubPaths

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
@Override
public Set<Path> listSubPaths(Path path) throws IOException {
  try {
    String prefix = pathToKey(path);
    if (!prefix.endsWith(PATH_DELIMITER)) {
      prefix += PATH_DELIMITER;
    }
    S3Object[] objects = s3Service.listObjects(bucket.getName(), prefix, PATH_DELIMITER);
    Set<Path> prefixes = new TreeSet<Path>();
    for (int i = 0; i < objects.length; i++) {
      prefixes.add(keyToPath(objects[i].getKey()));
    }
    prefixes.remove(path);
    return prefixes;
  } catch (S3ServiceException e) {
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:Jets3tFileSystemStore.java

示例12: listDeepSubPaths

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
@Override
public Set<Path> listDeepSubPaths(Path path) throws IOException {
  try {
    String prefix = pathToKey(path);
    if (!prefix.endsWith(PATH_DELIMITER)) {
      prefix += PATH_DELIMITER;
    }
    S3Object[] objects = s3Service.listObjects(bucket.getName(), prefix, null);
    Set<Path> prefixes = new TreeSet<Path>();
    for (int i = 0; i < objects.length; i++) {
      prefixes.add(keyToPath(objects[i].getKey()));
    }
    prefixes.remove(path);
    return prefixes;
  } catch (S3ServiceException e) {
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }    
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:Jets3tFileSystemStore.java

示例13: put

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
private void put(String key, InputStream in, long length, boolean storeMetadata)
    throws IOException {
  
  try {
    S3Object object = new S3Object(key);
    object.setDataInputStream(in);
    object.setContentType("binary/octet-stream");
    object.setContentLength(length);
    if (storeMetadata) {
      object.addAllMetadata(METADATA);
    }
    s3Service.putObject(bucket, object);
  } catch (S3ServiceException e) {
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:Jets3tFileSystemStore.java

示例14: dump

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
@Override
public void dump() throws IOException {
  StringBuilder sb = new StringBuilder("S3 Filesystem, ");
  sb.append(bucket.getName()).append("\n");
  try {
    S3Object[] objects = s3Service.listObjects(bucket.getName(), PATH_DELIMITER, null);
    for (int i = 0; i < objects.length; i++) {
      Path path = keyToPath(objects[i].getKey());
      sb.append(path).append("\n");
      INode m = retrieveINode(path);
      sb.append("\t").append(m.getFileType()).append("\n");
      if (m.getFileType() == FileType.DIRECTORY) {
        continue;
      }
      for (int j = 0; j < m.getBlocks().length; j++) {
        sb.append("\t").append(m.getBlocks()[j]).append("\n");
      }
    }
  } catch (S3ServiceException e) {
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }
  System.out.println(sb);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:Jets3tFileSystemStore.java

示例15: listAllPaths

import org.jets3t.service.model.S3Object; //导入依赖的package包/类
@Override
public Set<Path> listAllPaths() throws IOException {
  try {
    String prefix = urlEncode(Path.SEPARATOR);
    S3Object[] objects = s3Service.listObjects(bucket.getName(), prefix, null);
    Set<Path> prefixes = new TreeSet<Path>();
    for (int i = 0; i < objects.length; i++) {
      prefixes.add(keyToPath(objects[i].getKey()));
    }
    return prefixes;
  } catch (S3ServiceException e) {
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }   
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:MigrationTool.java


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