0

I'm trying to download files using Google Drive APIs V3 with alt=media option. But I can't start download in a web browser.

My query is:

GET https://www.googleapis.com/drive/v3/files/0B9jNhSvVjoIVM3dKcGRKRmVIOVU?alt=media

Its response is something like:

See the response of the query

I've tried the third option which is webContentLink with this one I can start download directly in browsers but I couldn't download files larger than 25MB.

So my question is : how can I start the download in browsers via the Google APIs ?

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Sarah
  • 11
  • 1
  • 5
  • its a file stream have you tried saving the response to a file locally? I don't think you are going to be able to download a file larger then 25 mb in the browser. https://developers.google.com/drive/v3/web/manage-downloads – Linda Lawton - DaImTo Jan 10 '17 at 10:44
  • I've tried using Blob, but there's a size limitation , for exemple, images larger than 10 MB can't be downloaded using Blob and the browsers either crash or the downloaded element will be named at the download bar 'download Failed - Network error'. I am trying to figure out how I can download any file directly in the browser via the Google Drive API V3. – Sarah Jan 10 '17 at 12:58
  • what are the response headers, i.e. is it setting content-type? For me both content-type and content-disposition: attachment are set correctly. If you are starting this via javascript, you may need to follow these instructions http://stackoverflow.com/a/20830337/1542667 – Yuri Schimke Jan 10 '17 at 13:17
  • There are 16 attributes is the response headers. The content-Type in my case is 'image/jpeg' and Content-Disposition is 'attachment'. – Sarah Jan 10 '17 at 13:33

1 Answers1

0

To download anything from Google Drive API using REST or Web, you need to know the webContentLink of the file. webContentLink of the file is obtained by making a call to Files.get.

The response is a link which downloads the file. However note that when you exceed the 25MB limit, Google might ask you about the 'scanning for virus' prompt. After that you'll be able to download the file directly.

Here's what my 30MB webContentLink looks like:

https://drive.google.com/uc?id=ABCDEFGccNwI7MkxfZHB5NzRfSVU&export=download

After the "scan for virus prompt", I was able to download it.

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56