#downloading file from Google Drive using node.js and react

3 messages · Page 1 of 1 (latest)

past cloak
#

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)
        }
    }
}
#

here is my code that im trying, but it does not do anything, i get status code 200 but no download is initiated

buoyant oar