1

Move File to Trash

by
Published Jul 27, 2022
Script gdrive Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 7 days ago
1
//native
2

3
type Gdrive = {
4
  token: string;
5
};
6
export async function main(gdrive_auth: Gdrive, fileId: string) {
7
  const supportsAllDrives = true;
8
  const DELETE_FILE_URL = `https://www.googleapis.com/drive/v2/files/${fileId}/?supportsAllDrives=${supportsAllDrives}`;
9

10
  const token = gdrive_auth["token"];
11

12
  const response = await fetch(DELETE_FILE_URL, {
13
    method: "DELETE",
14
    headers: {
15
      Authorization: "Bearer " + token,
16
      "Content-Type": "application/json",
17
    },
18
  });
19

20
  return "file moved to trash";
21
}
22

Other submissions
  • Submitted by rossmccrann Deno
    Created 399 days ago
    1
    type Gdrive = {
    2
      token: string;
    3
    };
    4
    export async function main(gdrive_auth: Gdrive, fileId: string) {
    5
      const supportsAllDrives = true;
    6
      const DELETE_FILE_URL = `https://www.googleapis.com/drive/v2/files/${fileId}/?supportsAllDrives=${supportsAllDrives}`;
    7
    
    
    8
      const token = gdrive_auth["token"];
    9
    
    
    10
      const response = await fetch(DELETE_FILE_URL, {
    11
        method: "DELETE",
    12
        headers: {
    13
          Authorization: "Bearer " + token,
    14
          "Content-Type": "application/json",
    15
        },
    16
      });
    17
    
    
    18
      return "file moved to trash";
    19
    }
    20