我正在切换到 Google Drive V3 API,但我无法检索到文档的流。
目标:我想将一个 google drive 文档推送到另一个位置,我需要检索文件流以便使用它将它推送到目标。
我找不到使用 Google Drive API V3 的方法!
在 V2 中,我使用了:
downloadUrl = file.ExportLinks[(string)ExportTable[file.MimeType]];
然后我可以使用类似的东西:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(downloadUrl));
我没有找到 V3 中的等效项。 我试过:
var getfile = _service.Files.Get(file.Id).Execute();
var request = _service.Files.Export(file.Id, getfile.MimeType);
System.IO.Stream stream = request.ExecuteAsStream();
流的内容是:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "fileNotExportable",
"message": "Export only supports Google Docs."
} ],
"code": 403,
"message": "Export only supports Google Docs."
}
}
当然,我们不希望将其下载到本地文件,然后从本地缓存的文件生成新的流。我们希望完全留在内存中。
谢谢你的帮助
最佳答案
您可以在 Migrate to Drive v3 中看到文档,它说:
The exportLinks field has been removed from files. To export Google Documents, use the files.export method instead.
检查该页面以了解 v3 中的其他更改。
关于google-drive-api - Google Drive API v3 的导出链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46325687/