I am trying to create a trigger where any new image file added to a google drive folder and it’s sunflowers gets sent to a database. It’s all working great for the folder itself but it won’t work for the sub folders. How do I get it to work for sub folders too?
Hi @houssam,
I understand you want to create a trigger for new image files added to a Google Drive folder and its subfolders. To achieve this, you can use the Google Drive API to monitor changes in the folder and its subfolders.
First, you’ll need to use the Google Drive app in Pipedream. Here’s an example component that listens for changes in a specific folder and its subfolders:
import { axios } from "@pipedream/platform";
export default defineComponent({
props: {
google: {
type: "app",
app: "google",
},
folderId: {
type: "string",
label: "Folder ID",
description: "The ID of the Google Drive folder you want to monitor",
},
},
async run({ steps, $ }) {
const response = await axios($, {
url: `https://www.googleapis.com/drive/v3/changes`,
headers: {
Authorization: `Bearer ${this.google.$auth.oauth_access_token}`,
},
params: {
q: `'${this.folderId}' in parents and mimeType contains 'image/' and trashed = false`,
includeItemsFromAllDrives: true,
supportsAllDrives: true,
},
});
return response.data;
},
});
Replace the folderId
prop with the ID of the Google Drive folder you want to monitor. This component will return the changes in the specified folder and its subfolders. You can then process the changes and send the new image files to your database.
Remember to check the Google Drive API documentation for more details on how to work with folders and files: Google Drive API | Google for Developers
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.