use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project amazon-s3-object-lambda-default-configuration by aws-samples.
the class GetObjectResponseHandler method writeObjectResponse.
public void writeObjectResponse(HttpResponse<InputStream> presignedResponse, byte[] responseObjectByteArray) {
Checksum checksum;
try {
checksum = this.checksumGenerator.getChecksum(responseObjectByteArray);
} catch (Exception e) {
this.logger.error("Error while writing object response" + e);
writeErrorResponse("Error while writing object response.", Error.SERVER_ERROR);
return;
}
var checksumMap = new HashMap<String, String>();
checksumMap.put("algorithm", checksum.getAlgorithm());
checksumMap.put("digest", checksum.getChecksum());
var checksumObjectMetaData = new ObjectMetadata();
checksumObjectMetaData.setUserMetadata(checksumMap);
this.s3Client.writeGetObjectResponse(new WriteGetObjectResponseRequest().withRequestRoute(event.outputRoute()).withRequestToken(event.outputToken()).withInputStream(new ByteArrayInputStream(responseObjectByteArray)).withMetadata(checksumObjectMetaData).withStatusCode(presignedResponse.statusCode()));
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project core-geonetwork by geonetwork.
the class S3Store method getResourceDescription.
@Override
public MetadataResource getResourceDescription(final ServiceContext context, final String metadataUuid, final MetadataResourceVisibility visibility, final String filename, Boolean approved) throws Exception {
int metadataId = getAndCheckMetadataId(metadataUuid, approved);
final String key = getKey(metadataUuid, metadataId, visibility, filename);
try {
final ObjectMetadata metadata = s3.getClient().getObjectMetadata(s3.getBucket(), key);
return createResourceDescription(metadataUuid, visibility, filename, metadata.getContentLength(), metadata.getLastModified(), metadataId, approved);
} catch (AmazonServiceException e) {
return null;
}
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project core-geonetwork by geonetwork.
the class S3Store method patchResourceStatus.
@Override
public MetadataResource patchResourceStatus(final ServiceContext context, final String metadataUuid, final String resourceId, final MetadataResourceVisibility visibility, Boolean approved) throws Exception {
int metadataId = canEdit(context, metadataUuid, approved);
String sourceKey = null;
ObjectMetadata metadata = null;
for (MetadataResourceVisibility sourceVisibility : MetadataResourceVisibility.values()) {
final String key = getKey(metadataUuid, metadataId, sourceVisibility, resourceId);
try {
metadata = s3.getClient().getObjectMetadata(s3.getBucket(), key);
if (sourceVisibility != visibility) {
sourceKey = key;
break;
} else {
// already the good visibility
return createResourceDescription(metadataUuid, visibility, resourceId, metadata.getContentLength(), metadata.getLastModified(), metadataId, approved);
}
} catch (AmazonServiceException ignored) {
// ignored
}
}
if (sourceKey != null) {
final String destKey = getKey(metadataUuid, metadataId, visibility, resourceId);
final CopyObjectResult copyResult = s3.getClient().copyObject(s3.getBucket(), sourceKey, s3.getBucket(), destKey);
s3.getClient().deleteObject(s3.getBucket(), sourceKey);
return createResourceDescription(metadataUuid, visibility, resourceId, metadata.getContentLength(), copyResult.getLastModifiedDate(), metadataId, approved);
} else {
throw new ResourceNotFoundException(String.format("Metadata resource '%s' not found for metadata '%s'", resourceId, metadataUuid));
}
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project aws-swf-flow-library by aws.
the class AverageCalculatorActivitiesImpl method computeDataSizeForInputData.
@Override
public int computeDataSizeForInputData(String bucketName, String filename) {
ObjectMetadata metadata = storage.getObjectMetadata(bucketName, filename);
long size = metadata.getContentLength();
return (int) size / ROW_SIZE;
}
use of com.ibm.watson.visual_recognition.v4.model.ObjectMetadata in project goobi-workflow by intranda.
the class S3FileUtils method getLastModifiedDate.
@Override
public long getLastModifiedDate(Path path) throws IOException {
if (getPathStorageType(path) == StorageType.LOCAL) {
return nio.getLastModifiedDate(path);
}
ObjectMetadata om = s3.getObjectMetadata(getBucket(), path2Key(path));
if (om == null) {
// check everything inside prefix.
long lastModified = 0;
ObjectListing listing = s3.listObjects(getBucket(), path2Key(path));
for (S3ObjectSummary os : listing.getObjectSummaries()) {
if (os.getLastModified().getTime() > lastModified) {
lastModified = os.getLastModified().getTime();
}
}
while (listing.isTruncated()) {
listing = s3.listNextBatchOfObjects(listing);
for (S3ObjectSummary os : listing.getObjectSummaries()) {
if (os.getLastModified().getTime() > lastModified) {
lastModified = os.getLastModified().getTime();
}
}
}
return lastModified;
} else {
// return lastModified of object
return om.getLastModified().getTime();
}
}
Aggregations