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


Java StorageObject类代码示例

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


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

示例1: upload

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
@Override
public StorageObject upload(final Path file, final Local local, final BandwidthThrottle throttle,
                            final StreamListener listener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    if(Checksum.NONE == status.getChecksum()) {
        // The client-side checksum is passed to the BlackPearl gateway by supplying the applicable CRC HTTP header.
        // If this is done, the BlackPearl gateway verifies that the data received matches the checksum provided.
        // End-to-end data protection requires that the client provide the CRC when uploading the object and then
        // verify the CRC after downloading the object at a later time (see Get Object). The BlackPearl gateway also
        // verifies the CRC when reading from physical data stores so the gateway can identify problems before
        // transmitting data to the client.
        status.setChecksum(writer.checksum(file).compute(local.getInputStream(), status));
    }
    // Make sure file is available in cache
    final List<TransferStatus> chunks = bulk.query(Transfer.Type.upload, file, status);
    StorageObject stored = null;
    for(TransferStatus chunk : chunks) {
        chunk.setChecksum(new MD5ChecksumCompute().compute(local.getInputStream(), chunk));
        stored = super.upload(file, local, throttle, listener, chunk, callback);
    }
    return stored;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:22,代码来源:SpectraUploadFeature.java

示例2: testDeleteFile

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
@Test
public void testDeleteFile() throws Exception {
    final Host host = new Host(new SpectraProtocol() {
        @Override
        public Scheme getScheme() {
            return Scheme.http;
        }
    }, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(
            System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")
    ));
    final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(),
            new DefaultX509KeyManager());
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path container = new Path("cyberduck", EnumSet.of(Path.Type.volume));
    final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final byte[] content = RandomUtils.nextBytes(1024);
    final HttpResponseOutputStream<StorageObject> out = new S3WriteFeature(session).write(test, new TransferStatus().length(content.length), new DisabledConnectionCallback());
    IOUtils.write(content, out);
    out.close();
    assertTrue(new S3FindFeature(session).find(test));
    new S3MultipleDeleteFeature(session).delete(Arrays.asList(test, test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    assertFalse(new S3FindFeature(session).find(test));
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:26,代码来源:SpectraMultipleDeleteFeatureTest.java

示例3: upload

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
@Override
public StorageObject upload(final Path file, final Local local, final BandwidthThrottle throttle,
                            final StreamListener listener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    final S3Protocol.AuthenticationHeaderSignatureVersion signatureVersion = session.getSignatureVersion();
    switch(signatureVersion) {
        case AWS4HMACSHA256:
            if(Checksum.NONE == status.getChecksum()) {
                status.setChecksum(writer.checksum(file).compute(local.getInputStream(), status));
            }
            break;
    }
    try {
        return super.upload(file, local, throttle, listener, status, callback);
    }
    catch(InteroperabilityException e) {
        if(!session.getSignatureVersion().equals(signatureVersion)) {
            // Retry if upload fails with Header "x-amz-content-sha256" set to the hex-encoded SHA256 hash of the
            // request payload is required for AWS Version 4 request signing
            return this.upload(file, local, throttle, listener, status, callback);
        }
        throw e;
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:24,代码来源:S3SingleUploadService.java

示例4: upload

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
@Override
public StorageObject upload(final Path file, Local local, final BandwidthThrottle throttle, final StreamListener listener,
                            final TransferStatus status, final ConnectionCallback prompt) throws BackgroundException {
    if(status.getLength() > multipartThreshold) {
        if(!preferences.getBoolean("s3.upload.multipart")) {
            log.warn("Multipart upload is disabled with property s3.upload.multipart");
            // Disabled by user
            if(status.getLength() < preferences.getLong("s3.upload.multipart.required.threshold")) {
                // Use single upload service
                return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt);
            }
        }
        try {
            return new S3MultipartUploadService(session, writer).upload(file, local, throttle, listener, status, prompt);
        }
        catch(NotfoundException | InteroperabilityException e) {
            log.warn(String.format("Failure using multipart upload %s. Fallback to single upload.", e.getMessage()));
        }
    }
    // Use single upload service
    return new S3SingleUploadService(session, writer).upload(file, local, throttle, listener, status, prompt);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:23,代码来源:S3ThresholdUploadService.java

示例5: testMakeDirectoryEncrypted

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
@Test
public void testMakeDirectoryEncrypted() throws Exception {
    final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(
            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
    ));
    final S3Session session = new S3Session(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final Path test = new CryptoDirectoryFeature<StorageObject>(session, new S3DirectoryFeature(session, new S3WriteFeature(session)), new S3WriteFeature(session), cryptomator).mkdir(new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), null, new TransferStatus());
    assertTrue(test.getType().contains(Path.Type.placeholder));
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    new CryptoDeleteFeature(session, new S3DefaultDeleteFeature(session), cryptomator).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:20,代码来源:S3DirectoryFeatureTest.java

示例6: testMakeDirectoryLongFilenameEncrypted

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
@Test
public void testMakeDirectoryLongFilenameEncrypted() throws Exception {
    final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(
            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
    ));
    final S3Session session = new S3Session(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final Path test = new CryptoDirectoryFeature<StorageObject>(session, new S3DirectoryFeature(session, new S3WriteFeature(session)), new S3WriteFeature(session), cryptomator).mkdir(new Path(vault, new RandomStringGenerator.Builder().build().generate(130), EnumSet.of(Path.Type.directory)), null, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    new CryptoDeleteFeature(session, new S3DefaultDeleteFeature(session), cryptomator).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:19,代码来源:S3DirectoryFeatureTest.java

示例7: testTouchEncrypted

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
@Test
public void testTouchEncrypted() throws Exception {
    final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(
            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
    ));
    final S3Session session = new S3Session(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    new CryptoTouchFeature<StorageObject>(session, new S3TouchFeature(session), new S3WriteFeature(session), cryptomator).touch(test, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    new CryptoDeleteFeature(session, new S3DefaultDeleteFeature(session), cryptomator).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:20,代码来源:S3TouchFeatureTest.java

示例8: testTouchLongFilenameEncrypted

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
@Test
public void testTouchLongFilenameEncrypted() throws Exception {
    final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(
            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
    ));
    final S3Session session = new S3Session(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new RandomStringGenerator.Builder().build().generate(130), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    new CryptoTouchFeature<StorageObject>(session, new S3TouchFeature(session), new S3WriteFeature(session), cryptomator).touch(test, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new S3FindFeature(session), cryptomator).find(test));
    new CryptoDeleteFeature(session, new S3DefaultDeleteFeature(session), cryptomator).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:20,代码来源:S3TouchFeatureTest.java

示例9: testTouchEncryptedDefaultFeature

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
@Test
public void testTouchEncryptedDefaultFeature() throws Exception {
    final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(
            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
    ));
    final S3Session session = new S3Session(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    new CryptoTouchFeature<StorageObject>(session, new DefaultTouchFeature<StorageObject>(new S3SingleUploadService(session, new S3WriteFeature(session))), new S3WriteFeature(session), cryptomator).touch(test, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    new CryptoDeleteFeature(session, new S3DefaultDeleteFeature(session), cryptomator).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:20,代码来源:S3TouchFeatureTest.java

示例10: testListCryptomator

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
@Test
public void testListCryptomator() throws Exception {
    final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
            new Credentials(
                    System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
            ));
    final S3Session session = new S3Session(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    assertTrue(new CryptoListService(session, new S3ObjectListService(session), cryptomator).list(vault, new DisabledListProgressListener()).isEmpty());
    new CryptoTouchFeature<StorageObject>(session, new DefaultTouchFeature<StorageObject>(new S3SingleUploadService(session, new S3WriteFeature(session))), new S3WriteFeature(session), cryptomator).touch(test, new TransferStatus());
    assertEquals(test, new CryptoListService(session, new S3ObjectListService(session), cryptomator).list(vault, new DisabledListProgressListener()).get(0));
    new CryptoDeleteFeature(session, new S3DefaultDeleteFeature(session), cryptomator).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:22,代码来源:S3ListServiceTest.java

示例11: storeLargeFile

import org.jets3t.service.model.StorageObject; //导入依赖的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

示例12: retrieveMetadata

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
@Override
public FileMetadata retrieveMetadata(String key) throws IOException {
  StorageObject object = null;
  try {
    LOG.debug("Getting metadata for key: {} from bucket: {}",
        key, bucket.getName());
    object = s3Service.getObjectDetails(bucket.getName(), key);
    return new FileMetadata(key, object.getContentLength(),
        object.getLastModifiedDate().getTime());

  } catch (ServiceException e) {
    try {
      // process
      handleException(e, key);
      return null;
    } catch (FileNotFoundException fnfe) {
      // and downgrade missing files
      return null;
    }
  } finally {
    if (object != null) {
      object.closeDataInputStream();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:Jets3tNativeFileSystemStore.java

示例13: list

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
/**
 * list objects
 * @param prefix prefix
 * @param delimiter delimiter
 * @param maxListingLength max no. of entries
 * @param priorLastKey last key in any previous search
 * @return a list of matches
 * @throws IOException on any reported failure
 */

private PartialListing list(String prefix, String delimiter,
    int maxListingLength, String priorLastKey) throws IOException {
  try {
    if (!prefix.isEmpty() && !prefix.endsWith(PATH_DELIMITER)) {
      prefix += PATH_DELIMITER;
    }
    StorageObjectsChunk chunk = s3Service.listObjectsChunked(bucket.getName(),
        prefix, delimiter, maxListingLength, priorLastKey);
    
    FileMetadata[] fileMetadata =
      new FileMetadata[chunk.getObjects().length];
    for (int i = 0; i < fileMetadata.length; i++) {
      StorageObject object = chunk.getObjects()[i];
      fileMetadata[i] = new FileMetadata(object.getKey(),
          object.getContentLength(), object.getLastModifiedDate().getTime());
    }
    return new PartialListing(chunk.getPriorLastKey(), fileMetadata,
        chunk.getCommonPrefixes());
  } catch (ServiceException e) {
    handleException(e, prefix);
    return null; // never returned - keep compiler happy
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:34,代码来源:Jets3tNativeFileSystemStore.java

示例14: testUploadObjectAsMultiparts

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
/**
 * Test upload object as multiparts.
 *
 * @throws Exception the exception
 */
@Test
public void testUploadObjectAsMultiparts() throws Exception {
	s3RESTService.createBucket(AWS_S3_BUCKET);//create bucket for test
	// Create a large (11 MB) file
       File file = File.createTempFile("testLargeFile", ".txt");
       BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
       int offset = 0;
       while (offset < 11 * 1024 * 1024) {
           bos.write((offset++ % 256));
       }
       bos.close();
       
       StorageObject objectKey = new StorageObject(file);
	s3RESTService.uploadObjectAsMultiparts(AWS_S3_BUCKET,objectKey ,
			MultipartUtils.MIN_PART_SIZE);
	S3Object s3Obj = s3RESTService.getObject(AWS_S3_BUCKET, objectKey.getKey());
	assertEquals(true, s3Obj!=null);
	if(file!=null){
		file.delete();//Delete when operation completes.
	}
}
 
开发者ID:abhinavmishra14,项目名称:aws-s3-utils,代码行数:27,代码来源:JetS3RESTServiceTest.java

示例15: uploadToBucket

import org.jets3t.service.model.StorageObject; //导入依赖的package包/类
public String uploadToBucket(String bucketname,
		DataInputStream dataInputStream, String fx) throws ServiceException {
	StorageObject[] sob = { new StorageObject() };
	sob[0].setDataInputStream(dataInputStream);
	sob[0].setName(fx);

	S3Bucket privateBket = s3service.getBucket(bucketname);
	AccessControlList bucketAcl = s3service.getBucketAcl(privateBket);

	sob[0].setAcl(bucketAcl);

	if (this.storageService.putObjects(bucketname, sob)) {
		StorageObject objectDetailsOnly = s3service.getObjectDetails(
				bucketname, fx);
		Logger.log("S3FS.uploadToBucket success: "
				+ objectDetailsOnly.getName());
		return objectDetailsOnly.getName();
	}
	Logger.error("S3FS.uploadToBucket: " + bucketname + " failed.");
	return null;
}
 
开发者ID:StarterInc,项目名称:Ignite,代码行数:22,代码来源:S3FS.java


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