Created by fatonramadani 228 days ago Viewed 564 times 0 Points
Download a file in gdrive as a base64 in gdrive to be used in another step
No comments yet
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)
}
}
No comments yet