2012-07-27 165 views
1

我写过一个程序,它创建一个文件对象,如果没有指定父项,默认情况下它会在根文件夹中创建。然后给定该文件的父代的id,它将检索根文件夹。未找到Google云端硬盘根文件夹文件错误

由于一些奇怪的原因,这不再有效,而不是返回根文件夹,我得到一个文件未找到错误。有任何想法吗?

感谢

更新

我试图在“根”传递作为检索的file_id文件,我遇到了同样的错误。

Get File By ID Error: File not found: 0AFrTA6Qc9-_TU9PVA 

下面是不过,我可以通过ID来获得其他文件的除了根用

def get_file_by_id session, file_id 
    drive = session.discovered_api("drive", "v2") 
    result = session.execute api_method: drive.files.get, parameters: {'fileId' => file_id} 
    if result.status == 200 
    return result.data 
    else 
    raise "Get File By ID Error: #{result.data['error']['message']}" 
    end 
end 

功能。

+2

您授权了哪个范围? https://www.googleapis.com/auth/drive.file或https://www.googleapis.com/auth/drive – 2012-07-27 22:34:57

+0

我已授权以下范围https://www.googleapis.com/auth/drive.file , https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile – omarshammas 2012-07-28 01:56:51

回答

4

没有看到代码,很难说你做错了什么。但是,获取用户的根文件夹要比您所做的要简单得多!

您可以使用特殊的“根”ID来引用当前用户的根文件夹。

GET https://www.googleapis.com/drive/v2/files/root

这将返回约根文件夹中的信息。它也可在about collection

更新:有关根文件夹的详细信息仅适用于https://www.googleapis.com/auth/drive范围。在使用文件范围时,无法从Drive UI或Picker打开根文件夹,以授权应用程序访问。

+0

所以我尝试了你的建议并遇到了同样的错误。我在上面的问题中添加了更多细节。 – omarshammas 2012-07-27 18:51:51

+0

谢谢!我有范围drive.file而不是驱动器。 – omarshammas 2012-07-28 18:40:40

相关问题