stataru8 commented on PR #290: URL: https://github.com/apache/camel-karaf/pull/290#issuecomment-2120233823
HOW TO TEST camel-google-storage ? Install needed features in the Karaf container `feature:install camel-google-storage` `feature:install camel-blueprint` Obtain and copy your **google-cloud-key.json** into Karaf's **/deploy** folder - Install gcloud, https://cloud.google.com/sdk/docs/install#linux Login into Google Cloud `gcloud auth login` Create an service account - Set project ID (use gcloud projects list to list all projects) `gcloud config set project [PROJECT_ID]` - Create a service account `gcloud iam service-accounts create [SERVICE_ACCOUNT_NAME]` - Assign admin role to the service account `gcloud projects add-iam-policy-binding [PROJECT_ID] --member="serviceAccount:[SERVICE_ACCOUNT_NAME]@[PROJECT_ID].iam.gserviceaccount.com" --role="roles/admin"` Generate a JSON key file for the service account `gcloud iam service-accounts keys create C:/google-cloud-key.json --iam-account [SERVICE_ACCOUNT_NAME]@[PROJECT_ID].iam.gserviceaccount.com` Copy [camel-google-storage.xml](https://github.com/apache/camel-karaf/files/15376274/camel-google-storage.zip) into Karaf's **/deploy** folder <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" xsi:schemaLocation="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"> <bean id="googleStorage" class="org.apache.camel.component.google.storage.GoogleCloudStorageComponent"> <property name="configuration" ref="googleStorageConfig"/> </bean> <bean id="currentInstant" class="java.time.Instant" factory-method="now"/> <bean id="googleStorageConfig" class="org.apache.camel.component.google.storage.GoogleCloudStorageConfiguration"> <property name="serviceAccountKey" value="file://deploy/google-cloud-key.json"/> <property name="bucketName" value="camel-karaf-bucket-test{{bean:currentInstant.toEpochMilli}}"/> <property name="autoCreateBucket" value="true"/> </bean> <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route> <from uri="timer:producer?repeatCount=1"/> <!-- List what is on the bucket --> <to uri="googleStorage://{{bean:googleStorageConfig.getBucketName}}?operation=listObjects"/> <log message="List of objects in the bucket {{bean:googleStorageConfig.getBucketName}} before upload: ${body}"/> <!-- Upload an object to the bucket --> <setHeader name="CamelGoogleCloudStorageObjectName"> <constant>message.txt</constant> </setHeader> <setHeader name="Content-Type"> <constant>text/plain; charset=utf-8</constant> </setHeader> <setBody> <constant>Hello Google</constant> </setBody> <to uri="googleStorage://{{bean:googleStorageConfig.getBucketName}}"/> <log message="Uploaded an object to the bucket"/> <!-- List what is on the bucket --> <to uri="googleStorage://{{bean:googleStorageConfig.getBucketName}}?operation=listObjects"/> <log message="List of objects in the bucket {{bean:googleStorageConfig.getBucketName}} after upload: ${body}"/> <!-- Download object from the bucket --> <to uri="googleStorage://{{bean:googleStorageConfig.getBucketName}}?operation=getObject"/> <setHeader name="CamelFileName"> <simple>downloaded-message.txt</simple> </setHeader> <to uri="file://deploy"/> <log message="Object downloaded from the bucket to the deploy folder"/> <!-- Delete the object from the bucket --> <to uri="googleStorage://{{bean:googleStorageConfig.getBucketName}}?operation=deleteObject"/> <log message="Object deleted from the bucket: ${body}"/> <to uri="googleStorage://{{bean:googleStorageConfig.getBucketName}}?operation=listObjects"/> <log message="List of objects in the bucket {{bean:googleStorageConfig.getBucketName}} after delete: ${body}"/> <!-- Delete the bucket --> <to uri="googleStorage://{{bean:googleStorageConfig.getBucketName}}?operation=deleteBucket"/> <log message="Bucket deleted: ${body}"/> </route> </camelContext> </blueprint> Observe the logs from the Apache Camel Karaf console and check the Karaf's /deploy folder for a new file named '**downloaded-message.txt**'. `log:tail` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
