use of com.amazonaws.services.s3.model.ObjectMetadata in project YCSB by brianfrankcooper.
the class S3Client method getS3ObjectAndMetadata.
private Map.Entry<S3Object, ObjectMetadata> getS3ObjectAndMetadata(String bucket, String key, SSECustomerKey ssecLocal) {
GetObjectRequest getObjectRequest;
GetObjectMetadataRequest getObjectMetadataRequest;
if (ssecLocal != null) {
getObjectRequest = new GetObjectRequest(bucket, key).withSSECustomerKey(ssecLocal);
getObjectMetadataRequest = new GetObjectMetadataRequest(bucket, key).withSSECustomerKey(ssecLocal);
} else {
getObjectRequest = new GetObjectRequest(bucket, key);
getObjectMetadataRequest = new GetObjectMetadataRequest(bucket, key);
}
return new AbstractMap.SimpleEntry<>(s3Client.getObject(getObjectRequest), s3Client.getObjectMetadata(getObjectMetadataRequest));
}
use of com.amazonaws.services.s3.model.ObjectMetadata in project gradle by gradle.
the class S3Resource method getMetaData.
public ExternalResourceMetaData getMetaData() {
ObjectMetadata objectMetadata = s3Object.getObjectMetadata();
Date lastModified = objectMetadata.getLastModified();
return new DefaultExternalResourceMetaData(uri, lastModified.getTime(), getContentLength(), s3Object.getObjectMetadata().getContentType(), s3Object.getObjectMetadata().getETag(), // Passing null for sha1 - TODO - consider using the etag which is an MD5 hash of the file (when less than 5Gb)
null);
}
use of com.amazonaws.services.s3.model.ObjectMetadata in project gradle by gradle.
the class S3ResourceConnector method getMetaData.
public ExternalResourceMetaData getMetaData(URI location, boolean revalidate) {
LOGGER.debug("Attempting to get resource metadata: {}", location);
S3Object s3Object = s3Client.getMetaData(location);
if (s3Object == null) {
return null;
}
try {
ObjectMetadata objectMetadata = s3Object.getObjectMetadata();
return new DefaultExternalResourceMetaData(location, objectMetadata.getLastModified().getTime(), objectMetadata.getContentLength(), objectMetadata.getContentType(), objectMetadata.getETag(), // Passing null for sha1 - TODO - consider using the etag which is an MD5 hash of the file (when less than 5Gb)
null);
} finally {
IoActions.closeQuietly(s3Object);
}
}
use of com.amazonaws.services.s3.model.ObjectMetadata in project airpal by airbnb.
the class S3FilesResource method getFile.
@GET
@Path("/{filename}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getFile(@PathParam("filename") String filename) {
val outputKey = getOutputKey(filename);
val getRequest = new GetObjectRequest(outputBucket, outputKey);
final val object = s3Client.getObject(getRequest);
if (object == null) {
return Response.status(Response.Status.NOT_FOUND).build();
} else {
ObjectMetadata objectMetadata = object.getObjectMetadata();
Response.ResponseBuilder builder = Response.ok().type(objectMetadata.getContentType());
if (objectMetadata.getContentEncoding() != null) {
// gzip
builder = builder.encoding(objectMetadata.getContentEncoding());
}
return builder.entity(new StreamingOutput() {
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
try (InputStream objectData = object.getObjectContent()) {
ByteStreams.copy(objectData, output);
} finally {
output.close();
}
}
}).build();
}
}
use of com.amazonaws.services.s3.model.ObjectMetadata in project ice by Netflix.
the class BasicS3ApplicationGroupService method saveApplicationGroup.
public boolean saveApplicationGroup(ApplicationGroup appgroup) {
Map<String, ApplicationGroup> appgroups = getApplicationGroups();
appgroups.put(appgroup.name, appgroup);
try {
String json = getJson(appgroups);
s3Client.putObject(config.workS3BucketName, config.workS3BucketPrefix + "appgroups", IOUtils.toInputStream(json), new ObjectMetadata());
s3Client.putObject(config.workS3BucketName, config.workS3BucketPrefix + "copy_appgroups", IOUtils.toInputStream(json), new ObjectMetadata());
BasicS3ApplicationGroupService.logger.info("saved appgroup " + appgroup);
return true;
} catch (JSONException e) {
logger.error("Error saving appgroup " + appgroup, e);
return false;
}
}
Aggregations