import { encode } from "https://deno.land/std@0.82.0/encoding/base64.ts";
type Gdrive = {
token: string;
};
export async function main(gdrive_auth: Gdrive, fileId: string) {
const DOWNLOAD_FILE_URL = `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`;
const token = gdrive_auth["token"];
const response = await fetch(DOWNLOAD_FILE_URL, {
method: "GET",
headers: {
Authorization: "Bearer " + token,
Accept: "application/json",
},
});
if (response) {
const arrayBuffer = await response.arrayBuffer();
return encode(arrayBuffer);
}
}
Submitted by admin 469 days ago
import { encode } from "https://deno.land/std@0.82.0/encoding/base64.ts";
type Gdrive = {
token: string;
};
export async function main(
gdrive_auth: Gdrive,
fileId: string,
) {
const DOWNLOAD_FILE_URL =
`https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`;
const token = gdrive_auth["token"];
const response = await fetch(DOWNLOAD_FILE_URL, {
method: "GET",
headers: {
Authorization: "Bearer " + token,
Accept: "application/json",
},
});
if (response) {
const arrayBuffer = await response.arrayBuffer();
return encode(arrayBuffer)
}
}
Submitted by admin 472 days ago
import * as wmill from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { encode } from "https://deno.land/std@0.82.0/encoding/base64.ts";
export async function main(
gdrive_auth: wmill.Resource<"gdrive">,
fileId: string,
) {
const DOWNLOAD_FILE_URL =
`https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`;
const token = gdrive_auth["token"];
const response = await fetch(DOWNLOAD_FILE_URL, {
method: "GET",
headers: {
Authorization: "Bearer " + token,
Accept: "application/json",
},
});
if (response) {
const arrayBuffer = await response.arrayBuffer();
return encode(arrayBuffer)
}
}
Submitted by adam186 600 days ago
import * as wmill from "https://deno.land/x/windmill@v1.70.1/mod.ts";
import { encode } from "https://deno.land/std@0.82.0/encoding/base64.ts";
export async function main(
gdrive_auth: wmill.Resource<"gdrive">,
fileId: string,
) {
const DOWNLOAD_FILE_URL =
`https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`;
const token = gdrive_auth["token"];
const response = await fetch(DOWNLOAD_FILE_URL, {
method: "GET",
headers: {
Authorization: "Bearer " + token,
Accept: "application/json",
},
});
if (response) {
const arrayBuffer = await response.arrayBuffer();
return encode(arrayBuffer)
}
}
Submitted by adam186 635 days ago
import * as wmill from "https://deno.land/x/windmill@v1.23.0/mod.ts";
import { encode } from "https://deno.land/std@0.82.0/encoding/base64.ts";
export async function main(
gdrive_auth: wmill.Resource<"gdrive">,
fileId: string,
) {
const DOWNLOAD_FILE_URL =
`https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`;
const token = gdrive_auth["token"];
const response = await fetch(DOWNLOAD_FILE_URL, {
method: "GET",
headers: {
Authorization: "Bearer " + token,
Accept: "application/json",
},
});
if (response) {
const arrayBuffer = await response.arrayBuffer();
return encode(arrayBuffer)
}
}
Submitted by fatonramadani 839 days ago
import * as wmill from "https://deno.land/x/windmill@v1.23.0/mod.ts";
import { encode } from "https://deno.land/std@0.82.0/encoding/base64.ts";
export async function main(
gdrive_auth: wmill.Resource<"gdrive">,
fileId: string,
) {
const DOWNLOAD_FILE_URL =
`https://www.googleapis.com/drive/v3/files/${fileId}?alt=media`;
const token = gdrive_auth["token"];
const fileResponse = await fetch(DOWNLOAD_FILE_URL, {
method: "GET",
headers: {
Authorization: "Bearer " + token,
Accept: "application/json",
},
});
if (fileResponse.body) {
const type = fileResponse.headers.get("Content-Type");
const arrayBuffer = await fileResponse.arrayBuffer();
return `data:${type};base64,${encode(arrayBuffer)}`;
}
}
Submitted by fatonramadani 839 days ago