use of com.formkiq.aws.s3.S3ObjectMetadata in project iceberg by apache.
the class MockS3Client method putObject.
@Override
public PutObjectResult putObject(PutObjectRequest request) {
S3ObjectMetadata metadata = request.getObjectMetadata();
objectData.put(createId(request.getBucketName(), request.getKey()), ObjectData.create(convertContent(request.getEntity()), metadata));
return new PutObjectResult();
}
use of com.formkiq.aws.s3.S3ObjectMetadata in project iceberg by apache.
the class ObjectData method createFullMetadata.
public S3ObjectMetadata createFullMetadata() {
S3ObjectMetadata metadata = new S3ObjectMetadata();
metadata.setETag(DigestUtils.md5Hex(content));
metadata.setContentLength((long) content.length);
metadata.setUserMetadata(userMetadata);
return metadata;
}
use of com.formkiq.aws.s3.S3ObjectMetadata in project formkiq-core by formkiq.
the class StagingS3Create method copyFile.
/**
* Copies Documentid to a new file that is a {@link UUID}.
*
* @param s3Client {@link S3Client}
* @param logger {@link LambdaLogger}
* @param bucket {@link String}
* @param originalkey {@link String}
* @param date {@link Date}
*/
private void copyFile(final S3Client s3Client, final LambdaLogger logger, final String bucket, final String originalkey, final Date date) {
String siteId = getSiteId(originalkey);
String key = resetDatabaseKey(siteId, originalkey);
boolean uuid = isUuid(key);
String documentId = uuid ? key : UUID.randomUUID().toString();
String destKey = createDatabaseKey(siteId, documentId);
logger.log(String.format("Copying %s from bucket %s to %s in bucket %s.", originalkey, bucket, destKey, this.documentsBucket));
S3ObjectMetadata metadata = this.s3.getObjectMetadata(s3Client, bucket, originalkey);
String username = metadata.getMetadata().entrySet().stream().filter(s -> s.getKey().equalsIgnoreCase("userid")).findFirst().map(s -> s.getValue()).orElse("System");
DynamicDocumentItem doc = new DynamicDocumentItem(Collections.emptyMap());
doc.setDocumentId(documentId);
doc.setContentLength(metadata.getContentLength());
doc.setContentType(metadata.getContentType());
doc.setUserId(username);
doc.setChecksum(metadata.getEtag());
doc.setInsertedDate(date);
if (!uuid) {
doc.setPath(key);
}
this.service.saveDocumentItemWithTag(siteId, doc);
this.s3.copyObject(s3Client, bucket, originalkey, this.documentsBucket, destKey, metadata.getContentType());
}
use of com.formkiq.aws.s3.S3ObjectMetadata in project formkiq-core by formkiq.
the class AbstractAwsTest method verifyFileExistsInDocumentsS3.
/**
* Verify File exists in Documents S3 Bucket.
*
* @param s3 {@link S3Client}
* @param key {@link String}
* @param contentType {@link String}
* @throws InterruptedException InterruptedException
*/
protected void verifyFileExistsInDocumentsS3(final S3Client s3, final String key, final String contentType) throws InterruptedException {
while (true) {
S3ObjectMetadata meta = getS3Service().getObjectMetadata(s3, getDocumentsbucketname(), key);
if (meta.isObjectExists()) {
assertEquals(contentType, meta.getContentType());
break;
}
Thread.sleep(SLEEP);
}
}
use of com.formkiq.aws.s3.S3ObjectMetadata in project formkiq-core by formkiq.
the class AwsResourceTest method verifyFileNotExistInStagingS3.
/**
* Verify File does NOT exist in Staging S3 Bucket.
*
* @param s3 {@link S3Client}
* @param key {@link String}
* @throws InterruptedException InterruptedException
*/
private void verifyFileNotExistInStagingS3(final S3Client s3, final String key) throws InterruptedException {
while (true) {
S3ObjectMetadata meta = getS3Service().getObjectMetadata(s3, getStagingdocumentsbucketname(), key);
if (!meta.isObjectExists()) {
assertFalse(meta.isObjectExists());
break;
}
Thread.sleep(SLEEP);
}
}
Aggregations