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


Java S3Service.getBucket方法代码示例

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


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

示例1: 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

示例2: 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

示例3: generateFilename

import org.jets3t.service.S3Service; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public String generateFilename(IScope scope, String name, String extension, GenerationType type) {
   	logger.debug("Get stream directory: scope={}, name={}, type={}", new Object[]{scope, name, type.toString()});		
	StringBuilder path = new StringBuilder();
	// get the session id
	IConnection conn = Red5.getConnectionLocal();
	if (conn.hasAttribute("sessionId")) {
		String sessionId = conn.getStringAttribute("sessionId");
		path.append(sessionId);
		path.append('/');
	}
	// add resources name
	path.append(name);
	// add extension if we have one
       if (extension != null){
           // add extension
       	path.append(extension);
       }		
	// determine whether its playback or record
	if (type.equals(GenerationType.PLAYBACK)) {
		logger.debug("Playback path used");
		// look on s3 for the file first	
		boolean found = false;
		try {
			S3Service s3Service = new RestS3Service(awsCredentials);
			S3Bucket bucket = s3Service.getBucket(bucketName);
			String objectKey = path.toString();
			S3Object file = s3Service.getObject(bucket, objectKey);
			if (file != null) {
				S3Object details = s3Service.getObjectDetails(bucket, objectKey);
				logger.debug("Details - key: {} content type: {}", details.getKey(), details.getContentType()); 
				path.insert(0, bucket.getLocation());
				// set found flag
				found = true;
			}
		} catch (S3ServiceException e) {
			logger.warn("Error looking up media file", e);
		}
		// use local path
		if (!found) {
			logger.debug("File was not found on S3, using local playback location");
			path.insert(0, playbackPath);
		}
	} else {
		logger.debug("Record path used");
		path.insert(0, recordPath);
	}

       String fileName = path.toString();
       logger.debug("Generated filename: {}", fileName);
       return fileName;
}
 
开发者ID:Red5,项目名称:red5-examples,代码行数:53,代码来源:S3FilenameGenerator.java


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