是否通过Google云端硬盘API获取多个文件的先前修订版? [英] Fetching previous revisions of multiple files via Google Drive API?

查看:71
本文介绍了是否通过Google云端硬盘API获取多个文件的先前修订版?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试将一些Android项目导入Eclipse时,我注意到项目中的每个文件在导入后均为0字节.这些项目存储在云端硬盘中,因此有机会将它们还原到以前的版本.

While trying to import some Android projects into Eclipse, I have noticed that every file in the project is 0 bytes after they are imported. These projects are stored on Drive, so there is some chance of reverting them back to the previous version.

只有几个文件时,将文件还原为以前的版本很容易-只需通过浏览器即可.但是,我有数百个文件,每个文件都需要取回一个修订.到目前为止,我已经可以手动下载许多文件,但是必须有一种更好的方法.

Reverting files to previous versions is easy to do when you've got a few files - you simply do it through a browser. However, I have hundreds of files and I need to fetch one revision back for each. I have been able to download a number of files by hand thus far, but there has to be a better way.

我已经请求Google支持,并且实际上得到了答复,但是很明显,没有内置功能可以做到这一点.因此,我开始研究Drive API,但我发现可能会有一些学习上的弯路.

I have asked Google support and actually got a response back, but it's clear that there is no built-in functionality to do this. So I have started looking at the Drive API but I can see that there might be a bit of a learning curve.

想知道以前是否有人遇到过这种情况吗?理想情况下,我想标识一个文件夹,并为下面的每个文件获取文件的最新版本.如果有人对此有好的方法,我很想听听.

Wondering if anyone has run into this before? Ideally I would like to identify one folder and for each file underneath, fetch the last version of the file. If anyone has a good approach for this, I would love to hear it.

谢谢!

推荐答案

执行所需操作的伪代码

# get the id of the folder https://developers.google.com/drive/v2/reference/files/list
fid=file.list(q=title = 'foo')[0]
# get the children of that folder https://developers.google.com/drive/v2/reference/children/list
children = file.children(fid).maxresults=999
# for each child, 
for id in children.id
  # get the revisions https://developers.google.com/drive/v2/reference/revisions/get
  revisions = file.revisions(id)
  # iterate, or take item[1] whatever works best for you, and use its downloadUrl to fetch the file

您每次拨打电话时,都需要提供访问令牌.对于这样的事情,您可以使用oauth游乐场 https://developers.google.com/oauthplayground生成访问令牌. /

With each call that you make, you'll need to provide an access token. For something like this, you can generate an access token using the oauth playground https://developers.google.com/oauthplayground/

您还需要在cloud/api控制台 https://code中注册项目. google.com/apis/console/

You'll also need to register a project at the cloud/api console https://code.google.com/apis/console/

是的,做一件相当简单的事情是不成比例的.对于熟悉驱动器的人来说,这需要花几分钟的时间,而对于那些不熟悉驱动器的人来说,它应该花3天的时间.您可能想在freelancer.com上发布它.

So ye, it's a disproportionate amount of learning to do something fairly simple. It's a few minutes work for somebody familiar with drive, and I would guess 3 days for somebody who isn't. You might want to throw it up on freelancer.com.

这篇关于是否通过Google云端硬盘API获取多个文件的先前修订版?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆