Pushing files to GCS (Google Cloud Storage) using ODI and GSUTIL
Hi all, today’s post is a short one, but since I didn’t find any other post related to that in the Internet, I found it could be useful for someone else. Recently I came across a requirement to push CSV files to GCS using ODI. After some research, I saw that Google has a utility called “gsutil”, that is a tool that enables you to access Cloud Storage from the command-line. So, if something is accessible from a command-line, ODI can also do that for sure.
First we need to have gsutil installed in the server that will be used by ODI to run the OS Command (in my case it was Windows). After that, we need to configure how gsutil will connect to our GCS instance. Probably you will create a service account in GCS to be used by ODI that will contain the correct read/write permissions and from it you may download its private key file. This is a json file that contains a private key and all the login information that will be used to configure gsutil, so it may authenticate with GCS. Save the json file in the ODI agent server and run the following command there:
gcloud auth activate-service-account <ACCOUNT_NAME> –key-file=”<JSON_FILE_LOCATION>” –project=<GCS_PROJECT_NAME>
Now we are all set to start using ODI to issue commands to GCS. For us to push a csv file to the cloud, we would only need to create an ODI procedure, select “Operating System” as a Technology and write a simple CP command on it, like below:
gsutil cp “<CSV_FILE_TO_BE_UPLOADED>” gs://<GCS_BUCKET_NAME>
When you run the proc, the files will be pushed to the cloud. Very simple, but powerful example on what we may accomplish with ODI + gsutil. For a complete list of gsutil commands, please see its documentation page.
Hope you liked it. Thanks!
January 7, 2020 at 6:22 am
Hi,
is it possible to upload files to sharepoint?
Great article like the other.
Thank for your sharing
January 7, 2020 at 1:00 pm
Good question. Let me do some research and get back to you. Thanks for the comment!
January 7, 2020 at 4:01 pm
It seems that you may map your sharepoint to a driver letter in the server and then issue “copy” from a DOS command. If thats the case, you would be able to easily add it to an ODI procedure.
net use r: https://some.portal.org/documents [password] user:domainName\[username]
copy c:\somefile.txt r:\somefile.txt
More info here:https://social.technet.microsoft.com/wiki/contents/articles/4437.upload-files-from-a-local-machine-to-a-sharepoint-document-library-automatically-dos-command.aspx
February 24, 2021 at 10:12 am
Is there any way i can call my cloud function from on-premise Oracle Data Integrator.