-2

I want to upload a file to a Google cloud storage bucket.

With Java/Camel:

from("file://target/upload?delete=true")
        .routeId("GCP file upload route")
        .log("picked up: ${header.CamelFileNameOnly}")
        .process( e -> e.getIn().setHeader(OBJECT_NAME, "mypath/%s-%s.txt".formatted(UUID.randomUUID().toString(), e.getIn().getHeader("CamelFileNameOnly"))) )
        .to("google-storage://mybucket?serviceAccountKey={{gcp.service-account-key}}")
        .log("uploaded: ${header.CamelGoogleCloudStorageObjectName}")

With gcloud/bash

gcloud storage cp "target/upload/myfile.txt" gs://mybucket/mypath/

Same result, and the two methods take up around the same amount of time to execute.

The only big difference? Camel code brings up the whole file in memory before doing the upload.

How would you implement a solution in Camel that does this simple task without loading the file in memory? ie. streaming the content up to the bucket. For the time being I found this.

0

Browse other questions tagged or ask your own question.