forked from activepieces/activepieces
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request activepieces#6780 from maarteNNNN/main
feat(google-drive): add teamdrive to get-file-by-id step
- Loading branch information
Showing
2 changed files
with
28 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
51 changes: 27 additions & 24 deletions
51
packages/pieces/community/google-drive/src/lib/action/get-file-by-id.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}, | ||
}); |