无法使用Go语言下载Google Drive API中的文件。

huangapple go评论77阅读模式
英文:

Cannot download files using Google Drive API in Go

问题

我正在尝试使用Google Drive API for Go下载一些*.FIT文件,这些文件存储在我的Google Drive的私人文件夹中(Garmin 310XT数据)。

我已经按照这里找到的向导和指南进行操作,并成功获取了一个文件夹的完整文件列表。

我正在使用这个示例代码,但是我无法下载任何文件。
无论是文件的DownloadUrl还是ExportFormats属性都为空。
有人成功完成过这个操作吗?还是我漏掉了什么重要的东西?

编辑:
第一个问题是关于范围的,但是在将其更改为drive.DriveScope之后,我只能下载0字节的文件。


解决方案

使用正确的http.RoundTripper解决了0字节大小的问题。
(client.Transport)

英文:

I am trying to download some *.FIT files using Google Drive API for Go, from a private folder stored in my Google Drive. (Garmin 310XT data)

I have followed the wizard and guide found here, and have successfully obtained a full list of files from a folder by id.

I am using this sample code, but I cannot download any of the files.
Both the file DownloadUrl and the ExportFormats properties are always empty.
Has anyone successfully done this, or am I just missing something important?

Edit:
The first problem was about scope, but after changing it to drive.DriveScope I can only download 0 byte files.


Solved

Using the correct http.RoundTripper solved the 0 byte size issue.
(client.Transport)

答案1

得分: 1

文件是否受限?

请参阅文件文档中的labels.restricted

labels.restricted boolean 指定查看者和评论者是否被禁止下载、打印和复制该文件。

英文:

Is the file restricted?

See files docs under labels.restricted

labels.restricted boolean Whether viewers and commenters are prevented from downloading, printing, and copying this file.

huangapple
  • 本文由 发表于 2015年10月22日 14:11:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/33274427.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定