在 DrEdit 中列出来自 Google Drive 的所有文件和文件夹 [英] Listing All files and folders from Google Drive in DrEdit

查看:15
本文介绍了在 DrEdit 中列出来自 Google Drive 的所有文件和文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题是 (列出所有文件夹内容来自 Google Drive),但我没有找到答案.我也有同样的问题.如果我将文件上传到谷歌驱动器,我在列表中找不到它.只有我在 DrEdit 中创建的文件.我尝试将范围更改为 kGTLAuthScopeDrive 并将 mimeTipe 更改为 '.' 和所有 'application/vnd.google-apps.'.我下载了 DrEdit,在 google drive 控制台上创建了我的应用程序,获得了客户端 ID 和客户端密码,替换了 DrEdit 中的,一切正常.我可以创建文件并在我的驱动器根文件夹中检查它.我手动将一些文件上传到根文件夹,然后在 init authViewController 中将范围更改为 kGTLAuthScopeDrive,将 mimeType = 'text/plain' 更改为 mimeType = '/*' 或其他类型.我错过了什么?请帮我.

I know this question has been (Listing All Folder content from Google Drive), but i didn't found answer. I have the same problem. If i uploaded file to the google drive i can't find it in list. Only files which i created in DrEdit. I tried change scope to kGTLAuthScopeDrive and mimeTipe to '.' and all 'application/vnd.google-apps.'. I downloaded DrEdit, created my app on google drive console, got client id and client secret, replace ones in DrEdit, all is working. I can create file and check it in my drive root folder. I uploaded some file by hand in to root folder, then changed scope to kGTLAuthScopeDrive in init authViewController, changed mimeType = 'text/plain' to mimeType = '/*' or other type. What did I miss? Please, help me.

推荐答案

如果你想列出 google drive 中的所有文件和文件夹,使用这个方法.

If, you want to list all files and folders from google drive, use this method.

-(void)loadDriveFiles
{
GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
query.q = [NSString stringWithFormat:@"'%@' IN parents", @"root"];
[self.driveService executeQuery:query completionHandler:^(GTLServiceTicket *ticket,
                                                      GTLDriveFileList *files,
                                                      NSError *error) {
    if (error == nil)
    {
        driveFiles = [[NSMutableArray alloc] init]; // 
        [driveFiles addObjectsFromArray:files.items];

        for (GTLDriveFile *file in driveFiles)
             NSLog(@"File is %@", file.title);
    }
    else
    {
        NSLog(@"An error occurred: %@", error);
    }
}];
}

对于 Mime 类型,请参考 this,并在查询中使用 or 运算符.

For Mime types refer this, and use it in query using or operator.

example- GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
query.q = @" mimeType ='audio/mpeg' or mimeType ='audio/wav' or mimeType ='audio/aac' or mimeType ='audio/aiff'  or mimeType = 'video/mp4'  or mimeType = 'image/png' or mimeType = 'application/zip' ";

可用的 Mime 类型-

Mime Types available-

$mime_types= array(
                "xls" =>'application/vnd.ms-excel',
                "xlsx" =>'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                "xml" =>'text/xml',
                "ods"=>'application/vnd.oasis.opendocument.spreadsheet',
                "csv"=>'text/plain',
                "tmpl"=>'text/plain',
                "pdf"=> 'application/pdf',
                "php"=>'application/x-httpd-php',
                "jpg"=>'image/jpeg',
                "png"=>'image/png',
                "gif"=>'image/gif',
                "bmp"=>'image/bmp',
                "txt"=>'text/plain',
                "doc"=>'application/msword',
                "js"=>'text/js',
                "swf"=>'application/x-shockwave-flash',
                "mp3"=>'audio/mpeg',
                "zip"=>'application/zip',
                "rar"=>'application/rar',
                "tar"=>'application/tar',
                "arj"=>'application/arj',
                "cab"=>'application/cab',
                "html"=>'text/html',
                "htm"=>'text/html',
                "default"=>'application/octet-stream',
                "folder"=>'application/vnd.google-apps.folder'
                                       );

这篇关于在 DrEdit 中列出来自 Google Drive 的所有文件和文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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