-2

I used this link to make an original link into a download link: https://milanaryal.com/2015/direct-linking-to-your-files-on-dropbox-google-drive-and-onedrive/

Now how do I actually use that download link to download the file in JavaScript? I want to do something like:

link = 'https://drive.google.com/uc?export=download&id=FILE_ID';
let x = download(link); //now x is the download file

I looked it up and it seems like there are ways of doing this with HTML/jQuery, but I am not using those because I am working on the server side with Nodejs. I am doing this download thing because I want to check if the file is a pdf or text, parse the text, and then search through it using Elasticsearch.

ThePumpkinMaster
  • 2,181
  • 5
  • 22
  • 31

2 Answers2

1

It's easiest to use a module such as Request to do a HTTP get from a node script.

For example:

var request = require('request');

request.get('https://drive.google.com/uc?export=download&id=FILE_ID',
   function(err, res, body){
        if(err) return console.log(err);
        console.log(body);
});

Once the file has downloaded, the callback function is run with the downloaded file in the body variable

dtkaias
  • 781
  • 4
  • 14
0

If you only want to download the file, open it, search for data and delete it, you can easily edit this code snippet: https://stackoverflow.com/a/11944984/642977

Community
  • 1
  • 1
Philip
  • 3,486
  • 1
  • 24
  • 37