【问题标题】:Search for a file or folder from google drive api via the name of the file/folder?通过文件/文件夹的名称从 google drive api 搜索文件或文件夹?
【发布时间】:2021-08-03 09:09:57
【问题描述】:

我正在尝试制作一个可以搜索文件/文件夹的功能。如果文件/文件夹存在,那么它将返回 id 否则将在 PHP 中从驱动器返回 null,但每次我这样做都表明 q 中有一些错误。

An error occurred: {
    "error": {
        "errors": [
            {
                "domain": "global",
                "reason": "invalid",
                "message": "Invalid Value",
                "locationType": "parameter",
                "location": "q"
            }
        ],
        "code": 400,
        "message": "Invalid Value"
    }
}

查询是:-

//testing-folder-of-api is the name of the folder
mimeType=application/vnd.google-apps.folder and name='testing-folder-of-api'

我也尝试过改变它:

  1. mimeType!=application/vnd.google-apps.folder 如果不是文件
  2. name contains 'test.txt'title='test.txt' 按名称搜索。

我找到的解决方案是循环遍历所有文件并使用循环单独检查名称,这需要很长时间。

谁能告诉我怎么做。请!!

【问题讨论】:

    标签: php google-drive-api


    【解决方案1】:

    问题:

    您应该在'application/vnd.google-apps.folder' 周围添加单引号,如File-specific query terms 所述:

    mimeType:文件的 MIME 类型。用单引号 ' 括起来。

    解决办法:

    mimeType='application/vnd.google-apps.folder' and name='testing-folder-of-api'
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-13
    • 1970-01-01
    • 1970-01-01
    • 2020-07-01
    • 2022-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多