Read file content from google drive using

scheduled app integration that runs with intervals automatically, read a file content saved on google drive
and saves this file content to a sql instance

which component should I use to access the text file on google drive ?

and what about authentication

Hey @dareenhamdy , thanks for your question - We’re keeping an eye on this thread to ensure you get the answers you need, and we also invite the community to pitch in with their thoughts.

Your patience means a lot to us. Additionally, consider checking our articles and upcoming events! :blush:

Hi @dareenhamdy ,

Welcome to Google Cloud Community!

To implement this scheduled integration on Google Cloud Platform, the components you should consider are the following:

  • Google Drive API: You need to enable this API in your GCP project to access the data stored files on your Google Drive.
  • Cloud Function: A serverless platform that runs your code in the cloud. Using Cloud Scheduler you can set it up to automatically retrieve, process, and save the file’s content in your SQL instance.
  • Cloud SQL: This is where you will store your data.

For authentication, create a service account with the required permissions across all services. You can also refer to this documentation for guidance on configuring OAuth 2.0 for authorization.

For you to connect your Cloud Function to Cloud SQL, you may review this documentation for more details. You may also find it helpful to refer to a related discussion on Medium articles: automation of data from Google Drive, and scheduling Google Cloud Function.

I hope the above information is helpful.

1 Like

Hi @dareenhamdy , thank you for the question.

To read the contents from a file from google drive using app integration you need to do the following:

  • Create a google drive connection using OAuth 2.0 credentials.
  • Go to app integration to create an integration using the drive connection connector task.
  • Configure the connector to perform Action-> drive.files.export
  • In the input payload, provide two required parameters namely “fileId” and “mimeType”.
  • In the output payload, “ResponseBody” will have the contents of the file.

Below is an example of an input payload
{
“Query parameters” : {
“mimeType”: “text/plain”
},
“Path parameters”: {
“fileId”: “2lnvidvieEZcI9JdfZt6XFRC0p6uI0J_7PkF8iFDGrg8A”
}
}

fileId can be extracted from the file URL as follows:

PriyankaCh_0-1731649553036.png

2 Likes