1

using another answer on this site, I was able to find this curl script:

#!/bin/bash
fileid="0Bz-w5tutuZIYY3h5YlMzTjhnbGM"
filename="MyFile.tar.gz"
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename}

which is able to download large Google Drive files (which show a warning page).

Additionally, I was able to us the pip install gdown command:

gdown https://drive.google.com/uc?id=0Bz-w5tutuZIYY3h5YlMzTjhnbGM

or the pip install youtube-dl library:

youtube-dl https://drive.google.com/uc?id=0Bz-w5tutuZIYY3h5YlMzTjhnbGM`

I'm even able to run the gdown script from within NODE.js:

const {spawn} = require("child_process");
 var g = spawn("gdown", ["https://drive.google.com/uc?id=0Bz-w5tutuZIYY3h5YlMzTjhnbGM"]);
 g.stdout.on('data', (d) => {
    console.log(d.toString()); 
 });

 g.stderr.on('data', (d) => {
    console.log(d.toString()); 
 });

 g.on('close', (d) => {
    console.log("closed with: " + d.toString()); 
 });

The problem:

I want to be able to use Google Drive to host large files for a website, and to do that I need to be able to produce a direct download link. I was thinking something like making a GET request to mynodewebsite/GOOGLE_DRIVE_LINK, or even making a socket request to the node.js server asking it to get the link, and then waiting for the generated link response.

HOWEVER, although I'm able to slowly download the file using the above methods, how can I simply return the / a direct link to the file? DO I need to download the google drive file onto the node.js server, wait for it to finish processing, and then return the path to that file back to the client, and then delete it afterwards? That would kind of defeat the purpose for large files, since I want to use Google Drive as the complete hosting...

SO how can I simply return the direct Google Drive download LINK as opposed to downloading the whole thing?

EDIT:

When I try to open the newly created project: enter image description here

  • according to [this site](https://solvemethod.com/google-drive-direct-link/), apparently you can't, you can go for onedrive/dropbox thou – Eric Wong Feb 08 '19 at 15:19
  • You want to retrieve a direct link for downloading a shared large file in Google Drive. If my understanding is correct, how about using API key? When API key is used, the direct link becomes like ``https://www.googleapis.com/drive/v3/files/### fileId ###?alt=media&key=### API key ###``, because Drive API can be used. Because I'm not sure whether this is what you want, I posted it as a comment. If this was not what you want, I apologize. – Tanaike Feb 08 '19 at 23:10
  • @Tanaike Thanks I'll look into that, does that allow you to access it without having to verify the application, though? – B''H Bi'ezras -- Boruch Hashem Feb 08 '19 at 23:56
  • @bluejayke Yes. You can directly download the file with the endpoint. For example, when you put the endpoint including API key to own browser, you can directly download the file because of GET method. – Tanaike Feb 08 '19 at 23:58
  • @Tanaike Hi can you direct me to the link where you can setup the API key without verification? I'm looking on https://developers.google.com/drive/api/v3/install and it seems that you need to verify it... – B''H Bi'ezras -- Boruch Hashem Feb 09 '19 at 00:06
  • @bluejayke I'm sorry. I cannot understand about your current situation. You don't know how to retrieve API key? – Tanaike Feb 09 '19 at 00:08
  • @Tanaike I actually thought I did it once with a javascript application, but that was only through authorizing in the browser, I forgot how to do it in the google console – B''H Bi'ezras -- Boruch Hashem Feb 09 '19 at 00:25
  • @Tanaike when I try to create credentials "from an application" in the browser, it gives me: Application data cannot be accessed securely from a web browser. Please consider selecting another platform. – B''H Bi'ezras -- Boruch Hashem Feb 09 '19 at 00:26
  • @bluejayke When users access to the endpoint like ``https://www.googleapis.com/drive/v3/files/### fileId ###?alt=media&key=### API key ###`` by own browser, no authorization screen is shown. If you have API key, you can test it. Is my understanding your situation correct? – Tanaike Feb 09 '19 at 00:28
  • @Tanaike yes but where do I get the API key? I can find the "get credentials" option in the google console, but the API section seems to be missing. Are they the same thing? – B''H Bi'ezras -- Boruch Hashem Feb 09 '19 at 00:29
  • @bluejayke If you need how to retrieve API key, how about this flow? https://github.com/tanaikech/goodls#retrieve-api-key – Tanaike Feb 09 '19 at 00:30
  • @Tanaike thanks but it seems the layout has changed, ""Google Cloud Platform" of upper left of window." doesn't seem to exist, all I see for Google Cloud Platform is Google Cloud Platform status at the upper right of the screen – B''H Bi'ezras -- Boruch Hashem Feb 09 '19 at 00:32
  • @bluejayke In my environment, I can see it. It seems that the layout has not changed. So I cannot understand about your current situation. Can you provide the detail information of your current situation? – Tanaike Feb 09 '19 at 00:35
  • @Tanaike where is "Select Project" exactly? – B''H Bi'ezras -- Boruch Hashem Feb 09 '19 at 00:37
  • @bluejayke I'm sorry. I cannot understand about your current situation. – Tanaike Feb 09 '19 at 00:38
  • @Tanaike In your post you say "Click select project at the right side of "Google Cloud Platform" of upper left of window." where is this "select project" button? – B''H Bi'ezras -- Boruch Hashem Feb 09 '19 at 00:40
  • @bluejayke In my environment, I can see it at the right side of "Google Cloud Platform" of upper left of window. – Tanaike Feb 09 '19 at 00:41
  • @Tanaike for me I only see Google CLoud platform status, not google cloud platform – B''H Bi'ezras -- Boruch Hashem Feb 09 '19 at 00:57
  • @bluejayke Can I ask you about your current situation? You have created new project? If you have never created new project, you can create it at [here](https://console.cloud.google.com/cloud-resource-manager?hl=en). When you create the new project, I think that you can use [the flow](https://github.com/tanaikech/goodls#retrieve-api-key) after "Click "NEW PROJECT"". – Tanaike Feb 09 '19 at 01:11
  • @bluejayke Is there anything that I can do for your question? If my proposal was not useful for your situation. I have to apologize and modify it. – Tanaike Feb 11 '19 at 23:56
  • @Tanaike Hi thanks for your help and I see you updated the guthub, although see my edit, as I can't find the next step in your instructions to "Click "Enable APIs and get credentials like keys". Maybe making a video tutorial or walk through with screenshots would be helpful? – B''H Bi'ezras -- Boruch Hashem Feb 12 '19 at 00:48
  • @bluejayke Can I see the screenshots of your current situation? – Tanaike Feb 12 '19 at 00:50
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/188242/discussion-between-bluejayke-and-tanaike). – B''H Bi'ezras -- Boruch Hashem Feb 12 '19 at 00:50

1 Answers1

1

When you want to retrieve a direct link for downloading a shared large file in Google Drive, you can use the endpoint using API key. The endpoint is as follows.

https://www.googleapis.com/drive/v3/files/### fileId ###?alt=media&key=### API key ###

You can use the endpoint as the direct link and download the file.

References:

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • 2
    Thanks! And BTW for anyone else out there: once you have the API key, just copy the public ID of the folder and plug it in here: https://www.googleapis.com/drive/v3/files?q=%27{YOUR FOLDER ID}%27+in+parents&key={YOUR API KEY} without the brackets, and then just get that data with nodeJS or anything else, and you've got a website! – B''H Bi'ezras -- Boruch Hashem Feb 12 '19 at 04:21
  • @bluejayke Thank you for your additional information. – Tanaike Feb 12 '19 at 04:37
  • Hi BTW, when I try to get the content of this page with a simple node-fetch tecnique, it is taking a LONG time (from 4000ms for the basic JSON to 35000ms for a particular file), see my new question: https://stackoverflow.com/questions/54666261/node-js-how-to-get-content-of-google-drive-api-in-the-fastest-way-possible – B''H Bi'ezras -- Boruch Hashem Feb 13 '19 at 09:34
  • @bluejayke In my current situation, I cannot find the issue and answer soon because I have never experienced the situation. I apologize for my poor skill and experiences. – Tanaike Feb 14 '19 at 00:49
  • @bluejayke, thank you very much! These characters took me a few days - on api explorer page it worked, but on postman not. But now it's ok. Really thank you! – recvec Jul 26 '19 at 09:20