use of com.formkiq.aws.s3.S3Service in project formkiq-core by formkiq.
the class PublicWebhooksRequestHandler method putObjectToStaging.
/**
* Put Object to Staging Bucket.
* @param logger {@link LambdaLogger}
* @param awsservice {@link AwsServiceCache}
* @param item {@link DynamicObject}
* @param siteId {@link String}
*/
private void putObjectToStaging(final LambdaLogger logger, final AwsServiceCache awsservice, final DynamicObject item, final String siteId) {
String s = GSON.toJson(item);
byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
String key = createDatabaseKey(siteId, item.getString("documentId") + FORMKIQ_DOC_EXT);
logger.log("s3 putObject " + key + " into bucket " + awsservice.stages3bucket());
S3Service s3 = awsservice.s3Service();
try (S3Client client = s3.buildClient()) {
s3.putObject(client, awsservice.stages3bucket(), key, bytes, item.getString("contentType"));
}
}
use of com.formkiq.aws.s3.S3Service in project formkiq-core by formkiq.
the class DocumentIdRequestHandler method putObjectToStaging.
/**
* Put Object to Staging Bucket.
*
* @param logger {@link LambdaLogger}
* @param awsservice {@link AwsServiceCache}
* @param maxDocumentCount {@link String}
* @param siteId {@link String}
* @param item {@link DynamicObject}
*/
private void putObjectToStaging(final LambdaLogger logger, final AwsServiceCache awsservice, final String maxDocumentCount, final String siteId, final DynamicObject item) {
List<DynamicObject> documents = item.getList("documents");
item.put("documents", documents);
String s = GSON.toJson(item);
byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
String key = createDatabaseKey(siteId, item.getString("documentId") + FORMKIQ_DOC_EXT);
logger.log("s3 putObject " + key + " into bucket " + awsservice.stages3bucket());
S3Service s3 = awsservice.s3Service();
try (S3Client client = s3.buildClient()) {
s3.putObject(client, awsservice.stages3bucket(), key, bytes, item.getString("contentType"));
if (maxDocumentCount != null) {
awsservice.documentCountService().incrementDocumentCount(siteId);
}
}
}
Aggregations