1

Copy File

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, fileId: string) {
7
  const supportsAllDrives = true;
8
  const COPY_FILE_URL = `https://www.googleapis.com/drive/v3/files/${fileId}/copy/?supportsAllDrives=${supportsAllDrives}`;
9

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

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

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

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, 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