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


Java S3Object.setKey方法代码示例

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


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

示例1: deploy

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
public void deploy(File jarFile) {
	String deployBucket = getOrCry("deployBucket");
	String deployFilename = getOrCry("deployFilename");

	try {
		getStorage().getOrCreateBucket(deployBucket);
		AccessControlList bucketAcl = getStorage().getBucketAcl(
				deployBucket);
		bucketAcl.grantPermission(GroupGrantee.ALL_USERS,
				Permission.PERMISSION_READ);

		S3Object statFileObject = new S3Object(jarFile);
		statFileObject.setKey(deployFilename);
		statFileObject.setAcl(bucketAcl);

		getStorage().putObject(deployBucket, statFileObject);

		log.info("File " + jarFile + " now accessible at " + getJarUrl());
	} catch (Exception e) {
		log.warn("Failed to deploy or set permissions in bucket  "
				+ deployBucket + ", key " + deployFilename, e);
	}
}
 
开发者ID:JulianEberius,项目名称:dwtc-extractor,代码行数:24,代码来源:Master.java

示例2: readFolderContents

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private void readFolderContents(File folder)
		throws NoSuchAlgorithmException, IOException, S3ServiceException {
	Iterator filesinFolder = fileUtils.iterateFiles(folder, null, true);
	while (filesinFolder.hasNext()) {
		Object file = filesinFolder.next();
		Logger.debug("File: " + file);
		String key = "testfilnamekey";
		if (folder.isDirectory()) {
			S3Object s3Obj = new S3Object(bucket, (File) file);
			s3Obj.setKey(key);
			s3Obj.setContentType(Mimetypes.getInstance().getMimetype(
					s3Obj.getKey()));
			s3Objs.add(s3Obj);
		} else {
			Logger.warn("S3FS.readFolderContents() File: "
					+ folder.getName() + " is not a folder.");
		}
	}
}
 
开发者ID:StarterInc,项目名称:Ignite,代码行数:20,代码来源:S3FS.java

示例3: call

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public Boolean call() throws Exception {
  final long start = System.currentTimeMillis();

  final String key = SingularityS3FormatHelper.getKey(uploadMetadata.getS3KeyFormat(), sequence, Files.getLastModifiedTime(file).toMillis(), Objects.toString(file.getFileName()), hostname);

  long fileSizeBytes = Files.size(file);
  LOG.info("{} Uploading {} to {}/{} (size {})", logIdentifier, file, s3Bucket.getName(), key, fileSizeBytes);

  try {
    S3Object object = new S3Object(s3Bucket, file.toFile());
    object.setKey(key);

    if (fileSizeBytes > configuration.getMaxSingleUploadSizeBytes()) {
      multipartUpload(object);
    } else {
      s3Service.putObject(s3Bucket, object);
    }
  } catch (Exception e) {
    LOG.warn("Exception uploading {}", file, e);
    throw e;
  }

  LOG.info("{} Uploaded {} in {}", logIdentifier, key, JavaUtils.duration(start));

  return true;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:28,代码来源:SingularityS3Uploader.java

示例4: upload

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private void upload(Worker worker, String inputFileKey,
		Iterable<Dataset> results) throws IOException,
		UnknownHostException, S3ServiceException, NoSuchAlgorithmException {

	long threadId = ThreadGuard.currentThread().getId();
	File tmpFile = new File("/tmp/" + threadId
			+ ".tmp");
	FileOutputStream output = new FileOutputStream(tmpFile);
	Writer writer = null;
	try {
		writer = new BufferedWriter(new OutputStreamWriter(
				new GZIPOutputStream(output), "UTF-8"));
		for (Dataset res : results) {
			writer.append(res.toJson());
			writer.append("\n");
		}
	} finally {
		if (writer != null)
			writer.close();
		output.close();
	}
	if (tmpFile.exists()) {
		S3Object outObject = new S3Object(tmpFile);
		outObject.setKey(makeOutputFileKey(inputFileKey));
		worker.getStorage().putObject(worker.resultBucket, outObject);
		tmpFile.delete();
	}
}
 
开发者ID:JulianEberius,项目名称:dwtc-extractor,代码行数:29,代码来源:Worker.java

示例5: prepareSignedObjects

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private SignedUrlAndObject[] prepareSignedObjects(S3Object[] objects,
    SignatureRequest[] signatureRequests, XmlGenerator xmlGenerator) throws Exception
{
    List signedObjects = new ArrayList();
    String firstDeclineReason = null;

    for (int i = 0; i < signatureRequests.length; i++) {
        SignatureRequest request = signatureRequests[i];
        S3Object object = objects[i];

        // Store summary information in XML document generator.
        if (xmlGenerator != null) {
            Map clonedMetadata = new HashMap();
            clonedMetadata.putAll(object.getMetadataMap());
            xmlGenerator.addSignatureRequest(object.getKey(), object.getBucketName(),
                clonedMetadata, request);
        }

        if (request.isSigned()) {
            // Update object with any changes dictated by Gatekeeper.
            if (request.getObjectKey() != null) {
                object.setKey(request.getObjectKey());
            }
            if (request.getBucketName() != null) {
                object.setBucketName(request.getBucketName());
            }
            if (request.getObjectMetadata() != null && request.getObjectMetadata().size() > 0) {
                object.replaceAllMetadata(request.getObjectMetadata());
            }

            SignedUrlAndObject urlAndObject = new SignedUrlAndObject(request.getSignedUrl(), object);
            signedObjects.add(urlAndObject);
        } else {
            // If ANY requests are declined, we will fail with a fatal error message.
            String declineReason = (request.getDeclineReason() == null
                ? "Unknown"
                : request.getDeclineReason());
            log.warn("Upload of '" + objects[i].getKey() + "' was declined for reason: "
                + declineReason);
            if (firstDeclineReason == null) {
                firstDeclineReason = declineReason;
            }
        }
    }
    if (firstDeclineReason != null) {
        throw new Exception("Your upload" + (objects.length > 1 ? "s were" : " was")
            + " declined by the Gatekeeper. Reason: " + firstDeclineReason);
    }
    return (SignedUrlAndObject[]) signedObjects.toArray(new SignedUrlAndObject[signedObjects.size()]);
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:51,代码来源:Uploader.java

示例6: sanitizeObjectKey

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private void sanitizeObjectKey(S3Object object) {
    if (object.getKey().startsWith(usersPath)) {
        object.setKey(object.getKey().substring(usersPath.length()));
    }
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:6,代码来源:CLObjectTableModel.java


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