0

On my webpage, I am downloading google drive files via the following approach:

https://drive.google.com/uc?export=download&id=${fileId}

However, this only works on computers. On phones (such as an android), it opens up google drive instead of downloading the file.

On the other hand, if I paste the link on my phone's browser, it downloads as expected instead of opening google drive.

One solution that seems to work even on phones is by using google drive api:

https://www.googleapis.com/drive/v3/files/FILE_ID?alt=media&key=YOUR_API_KEY

However, the name of the downloaded file is set to the file ID instead of the file name.

I've seen an answer which says to use Content-Disposition headers to set the file name, however, I do not have any server-side support, and apparently I will need expressjs to set content headers (Please tell me if I'm wrong) . My webpage has to be client-side only.

So how do I obtain a google drive download link that:

  1. Works everywhere without opening google drive (iPhone/iPads are an exception as they don't allow downloads)
  2. Lets me keep or set the file name instead of setting the file id as the downloaded file name.
2
  • apparently I will need expressjs to set content headers...you can't control what headers a 3rd-party server sets. expressjs would let you set headers, but only on your own pages in your own app - unless you used it as a proxy for google drive, but that would be pretty inefficient. Commented Mar 26 at 9:19
  • On phones (such as an android), it opens up google drive instead of downloading the file...this will be local settings on the phone. There doesn't seem to be a programming question here, it's more of a super-user issue I'd say - but correct me if I'm wrong. Commented Mar 26 at 9:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.