I’ve got a file in my Google Cloud Storage bucket that changes every half hour. I want to automatically copy this file to a specific Google Drive folder each time it updates. I’m thinking about using Google Cloud Functions to handle this but I’m pretty new to all this Google Cloud stuff and automation in general. What’s the best approach to set this up? Are there any specific APIs or services I should be using? Any help would be appreciated since I’m still learning how all these Google services work together.
Cloud Functions is an ideal solution for automating file transfers from Google Cloud Storage to Google Drive. I’ve implemented a similar setup using Cloud Functions alongside Pub/Sub notifications, which worked effectively. Begin by enabling the Cloud Storage and Google Drive APIs in your project. Configure a notification for the Cloud Storage bucket that triggers your function whenever the file updates. Inside the function, authenticate to the Drive API using a service account, retrieve the updated file from Cloud Storage, and upload it to Drive. Just be cautious about Drive API rate limits if you’re running this every 30 minutes; the authentication part can be somewhat challenging, but after it’s set up, the process becomes straightforward.
had this exact prob a few months back! switched to eventarc instead of pub/sub - way simpler setup. just a heads up, test the drive api quotas first since they get weird with frequent uploads. works great once you get it going tho.
You could also try Google Apps Script if you don’t want the complexity of Cloud Functions. I built something similar using Apps Script with a time trigger that checks my GCS bucket every 30 minutes for file changes. The nice thing is Apps Script already has Drive access built-in - no API authentication headaches. Just use UrlFetchApp to grab files from Cloud Storage and DriveApp to save them to Drive. Downside is it’s not event-driven like Cloud Functions, so there’s a small delay. But for a file updating every 30 minutes, it worked great for me. Plus debugging is way easier when you’re just getting started.