Skip to content

Commit 683ec4a

Browse files
authored
🤖 Merge PR DefinitelyTyped#71508 [google-apps-script] Fixed types for file download by @marekdedic
1 parent a2956e8 commit 683ec4a

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

types/google-apps-script/apis/drive_v2.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ declare namespace GoogleAppsScript {
111111
// Gets a file's metadata by ID.
112112
get(fileId: string): Drive.Schema.File;
113113
// Gets a file's metadata by ID.
114+
get(fileId: string, optionalArgs: Record<string, any> & { alt: "media" }): string;
115+
// Gets a file's metadata by ID.
114116
get(fileId: string, optionalArgs: Record<string, any>): Drive.Schema.File;
115117
// Insert a new file.
116118
insert(resource: Schema.File): Drive.Schema.File;

types/google-apps-script/apis/drive_v3.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,14 @@ declare namespace GoogleAppsScript {
13491349
/** Gets a file's metadata or content by ID. If you provide the URL parameter `alt=media`, then the response includes the file contents in the response body. Downloading content with `alt=media` only works if the file is stored in Drive. To download Google Docs, Sheets, and Slides use [`files.export`](/drive/api/reference/rest/v3/files/export) instead. For more information, see [Download & export files](/drive/api/guides/manage-downloads).
13501350
@param fileId The ID of the file.*/
13511351
get(fileId: string): Drive_v3.Drive.V3.Schema.File;
1352-
/** Gets a file's metadata or content by ID. If you provide the URL parameter `alt=media`, then the response includes the file contents in the response body. Downloading content with `alt=media` only works if the file is stored in Drive. To download Google Docs, Sheets, and Slides use [`files.export`](/drive/api/reference/rest/v3/files/export) instead. For more information, see [Download & export files](/drive/api/guides/manage-downloads).
1352+
/** Gets a file's content by ID. If you provide the URL parameter `alt=media`, then the response includes the file contents in the response body. Downloading content with `alt=media` only works if the file is stored in Drive. To download Google Docs, Sheets, and Slides use [`files.export`](/drive/api/reference/rest/v3/files/export) instead. For more information, see [Download & export files](/drive/api/guides/manage-downloads).
1353+
@param fileId The ID of the file.
1354+
@param optionalArgs Optional arguments.*/
1355+
get(
1356+
fileId: string,
1357+
optionalArgs: Record<string, any> & { alt: "media" },
1358+
): string;
1359+
/** Gets a file's metadata or content by ID.
13531360
@param fileId The ID of the file.
13541361
@param optionalArgs Optional arguments.*/
13551362
get(

types/google-apps-script/test/google-apps-script-tests.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,16 @@ function createFolder() {
11481148
console.log("Created Folder:", folder.name, folder.id);
11491149
}
11501150

1151+
function getFile() {
1152+
const file = Drive.Files.get("FileID");
1153+
console.log(file.name);
1154+
}
1155+
1156+
function getRawFile() {
1157+
const fileBlob: string = Drive.Files.get("FileID", { alt: "media" });
1158+
console.log(fileBlob);
1159+
}
1160+
11511161
// Example showing how to create a folder
11521162
function createDrive() {
11531163
const drive = Drive.Drives.create({

0 commit comments

Comments
 (0)