Reputation: 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:
Upvotes: 1
Views: 2844
Reputation: 201358
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.
Upvotes: 1