Skip to content

Commit

Permalink
dynamic s3
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosthe19916 committed Apr 26, 2020
1 parent 48ac7ae commit 6b1cc69
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package io.github.project.openubl.xmlsender.camel;

import io.github.project.openubl.xmlsender.models.FileType;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
import org.eclipse.microprofile.config.inject.ConfigProperty;
Expand All @@ -38,7 +37,7 @@ public void configure() throws Exception {
from("direct:filesystem-save-file")
.id("filesystem-save-file")
.choice()
.when(header("fileType").isEqualTo(FileType.XML))
.when(header("isZipFile").isEqualTo(false))
.marshal().zipFile()
.endChoice()
.end()
Expand All @@ -59,7 +58,12 @@ public void configure() throws Exception {
String filename = exchange.getIn().getBody(String.class);
byte[] bytes = Files.readAllBytes(Paths.get(filename));
exchange.getIn().setBody(bytes);
});
})
.choice()
.when(header("shouldUnzip").isEqualTo(true))
.unmarshal().zipFile()
.endChoice()
.end();

from("direct:filesystem-get-file-link")
.id("filesystem-get-file-link")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void configure() throws Exception {
exchange.getIn().setHeader(S3Constants.CONTENT_TYPE, "application/zip");
exchange.getIn().setHeader(S3Constants.CONTENT_DISPOSITION, "attachment;filename=\"${header.CamelFileName}\"");
})
.to("aws-s3:" + s3Bucket + "?deleteAfterWrite=true&amazonS3Client=#s3client")
.toD("aws-s3:" + s3Bucket + "?deleteAfterWrite=true&amazonS3Client=#s3client")
.process(exchange -> {
String documentID = exchange.getIn().getHeader(S3Constants.KEY, String.class);
exchange.getIn().setBody(documentID);
Expand All @@ -123,23 +123,20 @@ public void configure() throws Exception {
.endChoice()
.end();

from("direct:s3-get-file-util")
.pollEnrich().simple("aws-s3:"+ s3Bucket + "?amazonS3Client=#s3client&deleteAfterRead=false&fileName=${body}");

from("direct:s3-get-file-link")
.id("s3-get-file-link")
.setHeader(S3Constants.KEY, simple("${body}"))
.setHeader(S3Constants.S3_OPERATION, constant("downloadLink"))
.setHeader(S3Constants.DOWNLOAD_LINK_EXPIRATION, constant(linkExpiration))
.to("aws-s3:" + s3Bucket + "?amazonS3Client=#s3client")
.toD("aws-s3:" + s3Bucket + "?amazonS3Client=#s3client")
.process(exchange -> {
String downloadLink = exchange.getIn().getHeader(S3Constants.DOWNLOAD_LINK, String.class);
exchange.getIn().setBody(downloadLink);
});

from("direct:s3-delete-file")
.id("s3-delete-file")
.to("aws-s3:"+ s3Bucket + "?amazonS3Client=#s3client&operation=deleteObject");
.toD("aws-s3:"+ s3Bucket + "?amazonS3Client=#s3client&operation=deleteObject");
}

}
2 changes: 1 addition & 1 deletion api/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ openubl.sunat.username=12345678912MODDATOS
openubl.sunat.password=MODDATOS
openubl.sunat.url1=https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService

openubl.storage.type=s3
openubl.storage.type=filesystem
openubl.storage.filesystem.folder=/myFolder
openubl.storage.s3.bucket=project-openubl
openubl.storage.s3.access_key_id=BQA2GEXO711FVBVXDWKM
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.version>1.3.2.Final</quarkus.version>
<quarkus.version>1.4.1.Final</quarkus.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>

<sunat-web-services.version>2.0.0.Final</sunat-web-services.version>
Expand Down

0 comments on commit 6b1cc69

Please sign in to comment.