1 | |
2 |
|
3 | type Gdrive = { |
4 | token: string; |
5 | }; |
6 | export async function main(gdrive_auth: Gdrive, title: string) { |
7 | const supportsAllDrives = true; |
8 | const CREATE_FOLDER_URL = `https://www.googleapis.com/drive/v3/file/?supportsAllDrives=${supportsAllDrives}`; |
9 |
|
10 | const token = gdrive_auth["token"]; |
11 | const body = { |
12 | name: title, |
13 | mimeType: "application/vnd.google-apps.folder", |
14 | }; |
15 | const response = await fetch(CREATE_FOLDER_URL, { |
16 | method: "POST", |
17 | body: JSON.stringify(body), |
18 | headers: { |
19 | Authorization: "Bearer " + token, |
20 | "Content-Type": "application/json", |
21 | }, |
22 | }); |
23 |
|
24 | return await response.text(); |
25 | } |
26 |
|