1
Move File to Trash
One script reply has been approved by the moderators Verified
Created by rossmccrann 695 days ago Viewed 9212 times
0
Submitted by rossmccrann Deno
Verified 695 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