1

Create Folder

by
Published Jul 27, 2022
Script gdrive Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 6 days ago
1
//native
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

Other submissions
  • Submitted by rossmccrann Deno
    Created 398 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