use of com.amazonaws.services.s3.model.ObjectMetadata in project ice by Netflix.
the class BasicS3ApplicationGroupService method deleteApplicationGroup.
public boolean deleteApplicationGroup(String name) {
Map<String, ApplicationGroup> appgroups = getApplicationGroups();
ApplicationGroup appgroup = appgroups.remove(name);
try {
String json = getJson(appgroups);
s3Client.putObject(config.workS3BucketName, config.workS3BucketPrefix + "appgroups", new ByteArrayInputStream(json.getBytes()), new ObjectMetadata());
BasicS3ApplicationGroupService.logger.info("delete appgroup " + name + " " + appgroup);
return true;
} catch (JSONException e) {
logger.error("Error deleting appgroup " + appgroup, e);
return false;
}
}
use of com.amazonaws.services.s3.model.ObjectMetadata in project ice by Netflix.
the class AwsUtils method downloadFileIfChangedSince.
public static boolean downloadFileIfChangedSince(String bucketName, String bucketFilePrefix, File file, long milles, String accountId, String assumeRole, String externalId) {
AmazonS3Client s3Client = AwsUtils.s3Client;
try {
if (!StringUtils.isEmpty(accountId) && !StringUtils.isEmpty(assumeRole)) {
Credentials assumedCredentials = getAssumedCredentials(accountId, assumeRole, externalId);
s3Client = new AmazonS3Client(new BasicSessionCredentials(assumedCredentials.getAccessKeyId(), assumedCredentials.getSecretAccessKey(), assumedCredentials.getSessionToken()), clientConfig);
}
ObjectMetadata metadata = s3Client.getObjectMetadata(bucketName, bucketFilePrefix + file.getName());
boolean download = !file.exists() || metadata.getLastModified().getTime() > milles;
if (download) {
return download(s3Client, bucketName, bucketFilePrefix + file.getName(), file);
} else
return download;
} finally {
if (s3Client != AwsUtils.s3Client)
s3Client.shutdown();
}
}
use of com.amazonaws.services.s3.model.ObjectMetadata in project exhibitor by soabase.
the class S3Utils method simpleUploadFile.
public static ObjectMetadata simpleUploadFile(S3Client client, byte[] bytes, String bucket, String key) throws Exception {
byte[] md5 = md5(bytes, bytes.length);
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(bytes.length);
metadata.setLastModified(new Date());
metadata.setContentMD5(S3Utils.toBase64(md5));
PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, key, new ByteArrayInputStream(bytes), metadata);
PutObjectResult putObjectResult = client.putObject(putObjectRequest);
if (!putObjectResult.getETag().equals(S3Utils.toHex(md5))) {
throw new Exception("Unable to match MD5 for config");
}
return metadata;
}
use of com.amazonaws.services.s3.model.ObjectMetadata in project exhibitor by soabase.
the class S3ClientImpl method getObjectMetadata.
@Override
public ObjectMetadata getObjectMetadata(String bucket, String key) throws Exception {
RefCountedClient holder = client.get();
AmazonS3Client amazonS3Client = holder.useClient();
try {
return amazonS3Client.getObjectMetadata(bucket, key);
} finally {
holder.release();
}
}
use of com.amazonaws.services.s3.model.ObjectMetadata in project uPortal by Jasig.
the class AwsS3DynamicSkinService method innerSkinCssFileExists.
@Override
protected boolean innerSkinCssFileExists(DynamicSkinInstanceData data) {
final String objectKey = this.getCssObjectKey(data);
log.info(ATTEMPTING_TO_GET_FILE_METADATA_FROM_AWS_S3_LOG_MSG, this.awsS3BucketConfig.getBucketName(), objectKey);
final ObjectMetadata metadata = this.getMetadataFromAwsS3Bucket(objectKey);
log.info(FILE_METADATA_RETRIEVED_FROM_AWS_S3_LOG_MSG, this.awsS3BucketConfig.getBucketName(), objectKey);
if (metadata == null) {
return false;
} else {
final String uniqueTokenFromS3 = metadata.getUserMetaDataOf(SKIN_UNIQUE_TOKEN_METADATA_KEY);
return this.getUniqueToken(data).equals(uniqueTokenFromS3);
}
}
Aggregations