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


Java S3Service类代码示例

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


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

示例1: generateTorrentUrl

import org.jets3t.service.S3Service; //导入依赖的package包/类
private void generateTorrentUrl() {
    final S3Object[] objects = getSelectedObjects();

    if (objects.length != 1) {
        log.warn("Ignoring Generate Public URL object command, can only operate on a single object");
        return;
    }
    S3Object currentObject = objects[0];

    // Generate URL
    String torrentUrl = S3Service.createTorrentUrl(
        currentSelectedBucket.getName(), currentObject.getKey());

    // Display signed URL
    JOptionPane.showInputDialog(ownerFrame,
        "Torrent URL for '" + currentObject.getKey() + "'.",
        "Torrent URL", JOptionPane.INFORMATION_MESSAGE, null, null, torrentUrl);
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:19,代码来源:Cockpit.java

示例2: saveImage

import org.jets3t.service.S3Service; //导入依赖的package包/类
private void saveImage(String filename, MultipartFile image) 
      throws ImageUploadException {
  
  try {
    AWSCredentials awsCredentials = 
      new AWSCredentials(s3AccessKey, s3SecretKey);      
    S3Service s3 = new RestS3Service(awsCredentials);
    
    S3Bucket imageBucket = s3.getBucket("spitterImages");
    S3Object imageObject = new S3Object(filename);
    
    imageObject.setDataInputStream(
            new ByteArrayInputStream(image.getBytes()));
    imageObject.setContentLength(image.getBytes().length);
    imageObject.setContentType("image/jpeg");
    
    AccessControlList acl = new AccessControlList();
    acl.setOwner(imageBucket.getOwner());
    acl.grantPermission(GroupGrantee.ALL_USERS, 
            Permission.PERMISSION_READ);
    imageObject.setAcl(acl);
    s3.putObject(imageBucket, imageObject); 
  } catch (Exception e) {
    throw new ImageUploadException("Unable to save image", e);
  }
}
 
开发者ID:liuxianqiang,项目名称:spring-in-action,代码行数:27,代码来源:SpitterController.java

示例3: testBucketStatusLookup

import org.jets3t.service.S3Service; //导入依赖的package包/类
public void testBucketStatusLookup() throws Exception {
    String bucketName = getBucketNameForTest("testBucketStatusLookup");
    RestStorageService service = getStorageService(getCredentials());

    try {
        // Non-existent bucket
        int status = service.checkBucketStatus(bucketName);
        assertEquals(S3Service.BUCKET_STATUS__DOES_NOT_EXIST, status);

        // Bucket is owned by someone else
        // NOTE: This test will fail if you actually own the "testing" bucket,
        // or if it is owned by someone else but has been made publicly readable.
        status = service.checkBucketStatus("testing");
        assertEquals(S3Service.BUCKET_STATUS__ALREADY_CLAIMED, status);

        service.createBucket(bucketName);
        // Bucket now exists and is owned by me.
        status = service.checkBucketStatus(bucketName);
        assertEquals(S3Service.BUCKET_STATUS__MY_BUCKET, status);
    } finally {
        // Clean up
        service.deleteBucket(bucketName);
    }
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:25,代码来源:BaseStorageServiceTests.java

示例4: getBucketList

import org.jets3t.service.S3Service; //导入依赖的package包/类
public static List<String> getBucketList() {
	logger.debug("Get the bucket list");
	List<String> bucketList = new ArrayList<String>(3);
	try {
		S3Service s3Service = new RestS3Service(awsCredentials); 
		S3Bucket[] buckets = s3Service.listAllBuckets();
		for (S3Bucket bucket: buckets) {
			logger.debug("Bucket: {}", bucket.getName());
			bucketList.add(bucket.getName());
		}
		logger.debug("Bucket count: {}", buckets.length);
	} catch (S3ServiceException e) {
		logger.error("Error during bucket listing", e);
	}
	return bucketList;
}
 
开发者ID:Red5,项目名称:red5-examples,代码行数:17,代码来源:S3FilenameGenerator.java

示例5: getS3Bucket

import org.jets3t.service.S3Service; //导入依赖的package包/类
protected S3Bucket getS3Bucket() throws Exception {
  if ( bucket == null ) {
    String bucketName = getS3BucketName();
    // subtract out the name
    S3Service s3Service = fileSystem.getS3Service();
    if ( s3Service != null ) {
      ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
      try {
        Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
        bucket = s3Service.getBucket( bucketName );
      } finally {
        Thread.currentThread().setContextClassLoader( currentClassLoader );
      }
    } else {
      return null;
    }

  }
  return bucket;
}
 
开发者ID:pentaho,项目名称:pentaho-s3-vfs,代码行数:21,代码来源:S3FileObject.java

示例6: processSetToDirMultiThreaded

import org.jets3t.service.S3Service; //导入依赖的package包/类
private void processSetToDirMultiThreaded(S3Service service) throws ServiceException, IOException {
    List<S3Object> s3objects = new ArrayList<S3Object>();
    long totalLength = 0;

    this.project.log("Collecting objects for multithreaded upload to s3://" + getOperationBucket().getName(), Project.MSG_INFO);

    for (FileSet fileSet : this.fileSets) {
        DirectoryScanner ds = fileSet.getDirectoryScanner(this.project);
        String[] includedFiles = ds.getIncludedFiles();
        for (String file : includedFiles) {
            File sourceFile = new File(ds.getBasedir(), file);
            S3Object s3Object = createS3Object(service, getOperationBucket(), sourceFile, this.toDir + "/" + file);
            s3objects.add(s3Object);
            totalLength += sourceFile.length();

            logStart(sourceFile, s3Object);
        }
    }
    putFiles(service, getOperationBucket(), s3objects.toArray(new S3Object[s3objects.size()]), totalLength);
}
 
开发者ID:spring-projects,项目名称:aws-ant,代码行数:21,代码来源:Upload.java

示例7: buildDestinationPath

import org.jets3t.service.S3Service; //导入依赖的package包/类
private void buildDestinationPath(S3Service service, S3Bucket bucket, String destination) throws ServiceException, IOException {
    S3Object object;
    try {
        object = new S3Object(destination + "/", new byte[0]);
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    }
    if (this.publicRead) {
        object.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
    }
    service.putObject(bucket, object);

    int index = destination.lastIndexOf('/');
    if (index != -1) {
        buildDestinationPath(service, bucket, destination.substring(0, index));
    }
}
 
开发者ID:spring-projects,项目名称:aws-ant,代码行数:18,代码来源:Upload.java

示例8: S3LogResource

import org.jets3t.service.S3Service; //导入依赖的package包/类
@Inject
public S3LogResource(RequestManager requestManager, HistoryManager historyManager, RequestHistoryHelper requestHistoryHelper, TaskManager taskManager, DeployManager deployManager, Optional<S3Service> s3ServiceDefault,
    Optional<S3Configuration> configuration, SingularityAuthorizationHelper authorizationHelper, Optional<SingularityUser> user, Map<String, S3Service> s3GroupOverride) {
  super(historyManager, taskManager, deployManager, authorizationHelper, user);
  this.requestManager = requestManager;
  this.s3ServiceDefault = s3ServiceDefault;
  this.configuration = configuration;
  this.requestHistoryHelper = requestHistoryHelper;
  this.s3GroupOverride = s3GroupOverride;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:11,代码来源:S3LogResource.java

示例9: s3Service

import org.jets3t.service.S3Service; //导入依赖的package包/类
@Provides
@Singleton
public Optional<S3Service> s3Service(Optional<S3Configuration> config) throws S3ServiceException {
  if (!config.isPresent()) {
    return Optional.absent();
  }

  return Optional.<S3Service>of(new RestS3Service(new AWSCredentials(config.get().getS3AccessKey(), config.get().getS3SecretKey())));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:10,代码来源:SingularityMainModule.java

示例10: s3ServiceGroupOverrides

import org.jets3t.service.S3Service; //导入依赖的package包/类
@Provides
@Singleton
public Map<String, S3Service> s3ServiceGroupOverrides(Optional<S3Configuration> config) throws S3ServiceException {
  if (!config.isPresent() || config.get().getGroupOverrides().isEmpty()) {
    return Collections.emptyMap();
  }

  final ImmutableMap.Builder<String, S3Service> s3ServiceBuilder = ImmutableMap.builder();

  for (Map.Entry<String, S3GroupOverrideConfiguration> entry : config.get().getGroupOverrides().entrySet()) {
    s3ServiceBuilder.put(entry.getKey(), new RestS3Service(new AWSCredentials(entry.getValue().getS3AccessKey(), entry.getValue().getS3SecretKey())));
  }

  return s3ServiceBuilder.build();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:16,代码来源:SingularityMainModule.java

示例11: S3ArtifactChunkDownloader

import org.jets3t.service.S3Service; //导入依赖的package包/类
public S3ArtifactChunkDownloader(SingularityS3Configuration configuration, Logger log, S3Service s3, S3Artifact s3Artifact, Path downloadTo, int chunk, long chunkSize, long length, SingularityRunnerExceptionNotifier exceptionNotifier) {
  this.configuration = configuration;
  this.log = log;
  this.s3 = s3;
  this.s3Artifact = s3Artifact;
  this.downloadTo = downloadTo;
  this.chunk = chunk;
  this.chunkSize = chunkSize;
  this.length = length;
  this.exceptionNotifier = exceptionNotifier;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:12,代码来源:S3ArtifactChunkDownloader.java

示例12: Jets3tFileObject

import org.jets3t.service.S3Service; //导入依赖的package包/类
public Jets3tFileObject(FileName fileName,
                        Jets3tFileSystem fileSystem,
                        S3Service service, S3Bucket bucket) {
  super(fileName, fileSystem);
  this.service = service;
  this.bucket = bucket;
}
 
开发者ID:thinkberg,项目名称:moxo,代码行数:8,代码来源:Jets3tFileObject.java

示例13: S3ContentReader

import org.jets3t.service.S3Service; //导入依赖的package包/类
/**
 * Constructor that builds a URL based on the absolute path of the file.
 *
 * @param nodeUrl url of the content node.
 * @param s3Sevice the s3 service
 * @param bucket the bucket
 */
public S3ContentReader(final String nodeUrl, final S3Service s3Sevice,
		final S3Bucket bucket) {
	super(nodeUrl);
	this.nodeUrl = nodeUrl;
	this.s3Service = s3Sevice;
	this.bucket = bucket;
	getDetails();
}
 
开发者ID:abhinavmishra14,项目名称:alfresco-amazon-s3-content-store-integration,代码行数:16,代码来源:S3ContentReader.java

示例14: S3ContentWriter

import org.jets3t.service.S3Service; //导入依赖的package包/类
/**
 * Instantiates a new s3 content writer.
 *
 * @param nodeUrl the node url
 * @param existingContentReader the existing content reader
 * @param s3Service the s3
 * @param bucket the bucket
 */
public S3ContentWriter(final String nodeUrl, final ContentReader existingContentReader,
		final S3Service s3Service, final S3Bucket bucket) {
	super(nodeUrl, existingContentReader);
	this.nodeUrl = nodeUrl;
	this.s3Service=s3Service;
	this.bucket=bucket;
	this.uuid=GUID.generate();
	addListener(new S3StreamListener(this));
}
 
开发者ID:abhinavmishra14,项目名称:alfresco-amazon-s3-content-store-integration,代码行数:18,代码来源:S3ContentWriter.java

示例15: S3ServiceMulti

import org.jets3t.service.S3Service; //导入依赖的package包/类
/**
 * Construct a multi-threaded service based on an S3Service and which sends event notifications
 * to an event listening class, and which will send EVENT_IN_PROGRESS events at the specified
 * time interval.
 *
 * @param s3Service
 *        an S3Service implementation that will be used to perform S3 requests. This implementation
 *        <b>must</b> be thread-safe.
 * @param listener
 *        the event listener which will handle event notifications.
 * @param threadSleepTimeMS
 *        how many milliseconds to wait before sending each EVENT_IN_PROGRESS notification event.
 */
public S3ServiceMulti(
    S3Service s3Service, S3ServiceEventListener listener, long threadSleepTimeMS)
{
    this.s3Service = s3Service;
    addServiceEventListener(listener);
    this.sleepTime = threadSleepTimeMS;

    // Sanity-check the maximum thread and connection settings to ensure the maximum number
    // of connections is at least equal to the largest of the maximum thread counts, and warn
    // the use of potential problems.
    int adminMaxThreadCount = this.s3Service.getJetS3tProperties()
        .getIntProperty("s3service.admin-max-thread-count", 20);
    int maxThreadCount = this.s3Service.getJetS3tProperties()
        .getIntProperty("s3service.max-thread-count", 2);
    int maxConnectionCount = this.s3Service.getJetS3tProperties()
        .getIntProperty("httpclient.max-connections", 20);
    if (maxConnectionCount < maxThreadCount) {
        if (log.isWarnEnabled()) {
            log.warn("Insufficient connections available (httpclient.max-connections="
                + maxConnectionCount + ") to run " + maxThreadCount
                + " simultaneous threads (s3service.max-thread-count) - please adjust JetS3t settings");
        }
    }
    if (maxConnectionCount < adminMaxThreadCount) {
        if (log.isWarnEnabled()) {
            log.warn("Insufficient connections available (httpclient.max-connections="
                + maxConnectionCount + ") to run " + adminMaxThreadCount
                + " simultaneous admin threads (s3service.admin-max-thread-count) - please adjust JetS3t settings");
        }
    }
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:45,代码来源:S3ServiceMulti.java


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