Search in sources :

Example 11 with S3Service

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"));
    }
}
Also used : S3Client(software.amazon.awssdk.services.s3.S3Client) S3Service(com.formkiq.aws.s3.S3Service)

Example 12 with S3Service

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);
        }
    }
}
Also used : DynamicObject(com.formkiq.stacks.common.objects.DynamicObject) S3Client(software.amazon.awssdk.services.s3.S3Client) S3Service(com.formkiq.aws.s3.S3Service)

Aggregations

S3Service (com.formkiq.aws.s3.S3Service)11 S3Client (software.amazon.awssdk.services.s3.S3Client)8 S3ConnectionBuilder (com.formkiq.aws.s3.S3ConnectionBuilder)6 SnsConnectionBuilder (com.formkiq.aws.sns.SnsConnectionBuilder)4 SnsService (com.formkiq.aws.sns.SnsService)4 SqsConnectionBuilder (com.formkiq.aws.sqs.SqsConnectionBuilder)4 SqsService (com.formkiq.aws.sqs.SqsService)4 SsmServiceImpl (com.formkiq.aws.ssm.SsmServiceImpl)4 BeforeClass (org.junit.BeforeClass)4 Region (software.amazon.awssdk.regions.Region)4 SsmConnectionBuilder (com.formkiq.aws.ssm.SsmConnectionBuilder)3 DocumentServiceImpl (com.formkiq.stacks.dynamodb.DocumentServiceImpl)3 AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)3 ApiRequestHandlerResponse (com.formkiq.lambda.apigateway.ApiRequestHandlerResponse)2 ArtifactStoreService (ai.verta.modeldb.artifactStore.storageservice.ArtifactStoreService)1 NFSService (ai.verta.modeldb.artifactStore.storageservice.nfs.NFSService)1 S3Service (ai.verta.modeldb.artifactStore.storageservice.s3.S3Service)1 ModelDBException (ai.verta.modeldb.common.exceptions.ModelDBException)1 LambdaLogger (com.amazonaws.services.lambda.runtime.LambdaLogger)1 S3ObjectMetadata (com.formkiq.aws.s3.S3ObjectMetadata)1