1
Copy File
One script reply has been approved by the moderators Verified
Created by rossmccrann 861 days ago Viewed 9385 times
0
Submitted by rossmccrann Deno
Verified 861 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 COPY_FILE_URL = `https://www.googleapis.com/drive/v3/files/${fileId}/copy/?supportsAllDrives=${supportsAllDrives}`;
7

8
  const token = gdrive_auth["token"];
9

10
  const response = await fetch(COPY_FILE_URL, {
11
    method: "POST",
12
    //body: JSON.stringify(body),
13
    headers: {
14
      Authorization: "Bearer " + token,
15
      "Content-Type": "application/json",
16
    },
17
  });
18

19
  return await response.text();
20
}
21