尝试获取Google云端硬盘文件时出错 [英] Error when trying to get Google Drive File
问题描述
使用以下方式获取Google云端硬盘文件时出现错误:
I am getting an error when trying to get a Google Drive File using:
file = service.files().get(fileId=<googleDriveFileId>).execute()
错误是:
<HttpError 404 when requesting https://www.googleapis.com/drive/v2/files/0B6Cpn8NXwgGPQjB6ZlRjb21ZdXc?alt=json returned "File not found: 0B6Cpn8NXwgGPQjB6ZlRjb21ZdXc">
但是,当我直接在浏览器中复制并粘贴链接时:
< A HREF = https://www.googleapis.com/drive/v2/files/0B6Cpn8NXwgGPQjB6ZlRjb21ZdXc?alt=json 相对= nofollow> https://www.googleapis.com/drive/v2/files/0B6Cpn8NXwgGPQjB6ZlRjb21ZdXc? alt = json
However, when I copy and paste that link directly in the browser like this: https://www.googleapis.com/drive/v2/files/0B6Cpn8NXwgGPQjB6ZlRjb21ZdXc?alt=json
我得到一个不同的错误:
I get a different error:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit Exceeded. Please sign up",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit Exceeded. Please sign up"
}
}
我甚至没有接近超过每日限额的地方,控制台显示0%的使用率。
我知道fileId是正确的,我使用Google Picker获取fileId。
有什么想法?
I am no where even close to exceeding the daily limit, the console shows 0% usage. I know the fileId is correct, I am using Google Picker to get the fileId. Any ideas?
推荐答案
在其他地方我发现这是Google Drive的一个已知问题,他们正在努力解决。他们提供了以下解决方法,我已确认工作。
I have found elsewhere that this is known issue with Google Drive that they are working to resolve. They offer the following workaround that I have confirmed works.
在构建选择器时添加以下内容:
Add the following to when building the picker:
enableFeature(google.picker.Feature.MULTISELECT_ENABLED).
完整的代码:
complete code:
var picker = new google.picker.PickerBuilder().
addView(view).
addView(uploadView).
setAppId("pressomatic").
setCallback(pickerCallback).
enableFeature(google.picker.Feature.MULTISELECT_ENABLED).
build();
picker.setVisible(true);
同样的解决方法解决了我尝试上传到Google的特定文件夹时发布的另一个问题Picker在DocsUploadView上使用setParent。您仍然将相同的功能添加到Picker中,而不是DocsUploadView,并且所有功能都按照它应该的方式工作。
This same workaround solves another problem I have posted about, when trying to upload to a specific folder with Google Picker using setParent on a DocsUploadView. You still add the same feature to the Picker, not the DocsUploadView, and everything works as it should.
这篇关于尝试获取Google云端硬盘文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!