Mike Flynn
Mike Flynn

Reputation: 24325

DownloadUrl missing from metadata for file on Google Drive API

I am trying to download a file from the Google Drive API but there is no DownloadUrl field.

Download Documentation

var doc = data[google.picker.Response.DOCUMENTS][0];

                    var request = gapi.client.request({
                        'path': '/drive/v2/files/' + doc.id,
                        'method': 'GET',
                    });

                    request.execute(function (resp) {
                        addToFileCallback(resp);
                    });

Upvotes: 0

Views: 2451

Answers (1)

pinoyyid
pinoyyid

Reputation: 22286

Native google file types such as those you've mentioned don't have downloadUrls, they have an array of exportLinks. This is because their format is proprietary thus it wouldn't make any sense to download them. See developers.google.com/drive/v2/reference/files

There isn't really a need to check the mime type. Just use whichever of downloadUrl or an appropriate exportLink is present. Remember that the downloadUrl is short lived.

It's useful to use https://developers.google.com/drive/v2/reference/files/get#try-it or http://www.clevernote.co/app/drivecrud.html to get a close look at the export links that are available for any given doc type.

Upvotes: 2

Related Questions