本文整理汇总了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);
}
}
示例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.");
}
}
}
示例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;
}
示例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();
}
}
示例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()]);
}
示例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()));
}
}