Skip to content

Commit

Permalink
Merge pull request activepieces#6780 from maarteNNNN/main
Browse files Browse the repository at this point in the history
feat(google-drive): add teamdrive to get-file-by-id step
  • Loading branch information
kishanprmr authored Feb 5, 2025
2 parents 96131cc + e79988e commit 13eb443
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/pieces/community/google-drive/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-google-drive",
"version": "0.5.35"
"version": "0.5.36"
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import { googleDriveAuth } from '../../index';
import { Property, createAction } from "@activepieces/pieces-framework";
import { Property, createAction } from '@activepieces/pieces-framework';
import { google } from 'googleapis';
import { OAuth2Client } from 'googleapis-common';
import { common } from '../common';

export const googleDriveGetResourceById = createAction({
auth: googleDriveAuth,
name: 'get-file-or-folder-by-id',
displayName: 'Get File',
description: 'Get a file folder for files/sub-folders',
props: {
id: Property.ShortText({
displayName: 'File / Folder Id',
description: 'The Id of the file/folder to search for.',
required: true,
})
},
async run(context) {
const authClient = new OAuth2Client();
authClient.setCredentials(context.auth)
const drive = google.drive({ version: 'v3', auth: authClient });
const response = await drive.files.get({ fileId: context.propsValue.id });
auth: googleDriveAuth,
name: 'get-file-or-folder-by-id',
displayName: 'Get File',
description: 'Get a file folder for files/sub-folders',
props: {
id: Property.ShortText({
displayName: 'File / Folder Id',
description: 'The Id of the file/folder to search for.',
required: true,
}),
include_team_drives: common.properties.include_team_drives,
},
async run(context) {
const authClient = new OAuth2Client();
authClient.setCredentials(context.auth);
const drive = google.drive({ version: 'v3', auth: authClient });
const response = await drive.files.get({
fileId: context.propsValue.id,
supportsAllDrives: context.propsValue.include_team_drives,
});

if (response.data) {
return response.data;
} else {
console.log('The specified ID corresponds to a folder. Returning null.');
return null;
}

if (response.data) {
return response.data;
} else {
console.log('The specified ID corresponds to a folder. Returning null.');
return null;
}
},
});

0 comments on commit 13eb443

Please sign in to comment.