Hi i am uploading files to google drive through my web app, but i have no idea how to download it to clients computer, does anyone have experience with Google Drive and node.js?
export const downloadFile: RequestHandler = async (req, res, next) => {
try {
const fileId = req.params.fileId;
const file = await FileModel.findById(fileId);
if (!file) {
throw createHttpError(400, "File not found");
}
GoogleDriveService.downloadFile("1zKttn59T-40_XRFHB_dDlVYCD1YaDVEd");
res.status(200);
} catch (error) {
next()
}
}
export class GoogleDriveService {
static downloadFile = async (realFileId: string) => {
const fileId = realFileId;
const service = GoogleDriveService.getDriveService()
try {
const file = await service.files.get({
fileId: fileId,
alt: 'media',
});
console.log(file.status);
return file.status;
} catch (error) {
console.log(error)
}
}
}