本文介绍了Google云端硬盘API上的文件元数据缺少DownloadUrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Google Drive API下载文件,但是没有DownloadUrl字段.

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

下载文档

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);
                    });

推荐答案

诸如您提到的本地google文件类型没有downloadUrl,它们具有一系列exportLinks.这是因为它们的格式是专有的,因此下载它们没有任何意义.参见developers.google.com/drive/v2/reference/files

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

实际上并不需要检查哑剧类型.只需使用存在的downloadUrl或适当的exportLink中的任何一个即可.请记住,downloadUrl是短暂的.

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.

使用 https://developers.google很有用. com/drive/v2/reference/files/get#try-it http://www.clevernote.co/app/drivecrud.html 以仔细查看可用于任何给定文档类型的导出链接.

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.

这篇关于Google云端硬盘API上的文件元数据缺少DownloadUrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 00:19