20251125 save
This commit is contained in:
parent
922fa0e77a
commit
092f2ec0f3
11 changed files with 299 additions and 1 deletions
36
functions/generate_minutes/src/logics/googleDrive.ts
Normal file
36
functions/generate_minutes/src/logics/googleDrive.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { authenticate } from "@google-cloud/local-auth";
|
||||
import { JSONClient } from "google-auth-library/build/src/auth/googleauth";
|
||||
import { google } from "googleapis";
|
||||
import path from "path";
|
||||
|
||||
const SCOPES = ["https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file"]
|
||||
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
|
||||
|
||||
export const googleDriveController = {
|
||||
getAuth: async():Promise<any> => {
|
||||
const auth = await new google.auth.GoogleAuth({
|
||||
keyFile: CREDENTIALS_PATH,
|
||||
scopes: SCOPES,
|
||||
});
|
||||
return auth;
|
||||
},
|
||||
checkConnection: async() => {
|
||||
const auth = await googleDriveController.getAuth();
|
||||
// console.log("Google Drive client authenticated.");
|
||||
const drive = google.drive({ version: "v3", auth: auth});
|
||||
const folder = '1cCDJKusfrlDrJe2yHCR8pCHJXRqX-4Hw';
|
||||
const res = await drive.files.list({
|
||||
q: `'${folder}' in parents`,
|
||||
pageSize: 10,
|
||||
fields: "files(id, name)",
|
||||
});
|
||||
console.log("Files:");
|
||||
console.log(res.data.files);
|
||||
},
|
||||
uploadFile: async() => {
|
||||
|
||||
},
|
||||
createNewFile: async() => {
|
||||
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue