1
Create Folder
One script reply has been approved by the moderators Verified
Created by rossmccrann 611 days ago Viewed 2536 times
0
Submitted by rossmccrann Deno
Verified 611 days ago
1
type Gdrive = {
2
  token: string;
3
};
4
export async function main(gdrive_auth: Gdrive, title: string) {
5
  const supportsAllDrives = true;
6
  const CREATE_FOLDER_URL = `https://www.googleapis.com/drive/v3/file/?supportsAllDrives=${supportsAllDrives}`;
7

8
  const token = gdrive_auth["token"];
9
  const body = {
10
    name: title,
11
    mimeType: "application/vnd.google-apps.folder",
12
  };
13
  const response = await fetch(CREATE_FOLDER_URL, {
14
    method: "POST",
15
    body: JSON.stringify(body),
16
    headers: {
17
      Authorization: "Bearer " + token,
18
      "Content-Type": "application/json",
19
    },
20
  });
21

22
  return await response.text();
23
}
24