Google文档导出问题401,404和500

时间:2014-04-17 07:56:33

标签: api google-drive-api

我正在尝试使用Google Drive SDK将Google云端硬盘中的所有数据下载到本地文件夹中。大多数文档都是在没有任何问题的情但有一些文件有奇怪的错误。

首先,所有这些文件都列在Files: list结果中。 Files: get会返回有关这些文件的信息。

我看到这些文件归我用来下载文档的用户所有:

[userPermission] => Google_Permission Object
    (
        [withLink] => 
        [kind] => drive#permission
        [name] => 
        [value] => 
        [id] => me
        [authKey] => 
        [etag] => "I8bbqc4qdR0X_1JlJgkO3gbuFf8/HQBSku0dMcS5bNfsSFuNdlHwJmk"
        [role] => owner
        [photoLink] => 
        [type] => user
        [additionalRoles] => 
        [selfLink] => https://www.googleapis.com/drive/v2/files/..../permissions/me
    )

但是当我尝试使用exportLinks之一导出这些文件时,我收到了错误。

HTTP状态404

文件:

Sorry, the file you have requested does not exist.

电子表格:

Spreadsheet not found
Error 404

HTTP状态401

在其他帐户上,我收到HTTP状态401错误:

Permission denied
Error 401

HTTP状态500

最后,HTTP Status 500存在很多错误:

Conversion failed unexpectedly
Error 500

主要问题 - 我可以解决这些问题吗?如果没有我可以向用户说明这些问题?

  • 我可以告诉他们Google丢失了他们的数据(出现错误404时)吗?
  • 我可以保证稍后会出现文件(出现错误500时)吗?
  • 如果用户拥有自己的文档,错误401 Permission denied的可能性如何?

更新1:当我尝试导出时,它总是返回401

{
    "mimeType": "application/vnd.google-apps.spreadsheet",
    "thumbnailLink": null,
    "labels": {
        "restricted": false,
        "hidden": false,
        "viewed": false,
        "starred": false,
        "trashed": false
    },
    "indexableText": null,
    "explicitlyTrashed": null,
    "etag": "\"KYLl3b7q6n8KW2kbVvK9NFUdVkc/MTM4MjUzMDk0Mzc4Ng\"",
    "lastModifyingUserName": "*********",
    "writersCanShare": true,
    "id": "********************************",
    "title": "2012 09 14 col audit report lin",
    "ownerNames": [
        "***** *****"
    ],
    "sharedWithMeDate": "2013-10-23T12:21:57.688Z",
    "lastViewedByMeDate": null,
    "parents": [
        {
            "selfLink": "https://www.googleapis.com/drive/v2/files/********************************/parents/***************",
            "kind": "drive#parentReference",
            "id": "***************",
            "isRoot": true,
            "parentLink": "https://www.googleapis.com/drive/v2/files/***************"
        }
    ],
    "exportLinks": {
        "application/pdf": "https://docs.google.com/feeds/download/spreadsheets/Export?key=********************************&exportFormat=pdf",
        "application/x-vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/feeds/download/spreadsheets/Export?key=********************************&exportFormat=ods",
        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "https://docs.google.com/feeds/download/spreadsheets/Export?key=********************************&exportFormat=xlsx"
    },
    "originalFilename": null,
    "description": null,
    "webContentLink": null,
    "editable": true,
    "kind": "drive#file",
    "quotaBytesUsed": "0",
    "fileSize": null,
    "createdDate": "2012-09-14T19:41:23.142Z",
    "md5Checksum": null,
    "imageMediaMetadata": null,
    "embedLink": "https://docs.google.com/a/mcclatchy.com/spreadsheet/ccc?key=********************************&output=html&chrome=false&widget=true",
    "alternateLink": "https://docs.google.com/a/mcclatchy.com/spreadsheet/ccc?key=********************************&usp=drivesdk",
    "modifiedByMeDate": null,
    "downloadUrl": null,
    "userPermission": {
        "withLink": null,
        "kind": "drive#permission",
        "name": null,
        "value": null,
        "id": "me",
        "authKey": null,
        "etag": "\"KYLl3b7q6n8KW2kbVvK9NFUdVkc/0Woj6kzdwLqBirUxVylXMFf6UNc\"",
        "role": "owner",
        "photoLink": null,
        "type": "user",
        "additionalRoles": null,
        "selfLink": "https://www.googleapis.com/drive/v2/files/********************************/permissions/me"
    },
    "fileExtension": null,
    "selfLink": "https://www.googleapis.com/drive/v2/files/********************************",
    "modifiedDate": "2013-10-23T12:22:23.786Z",
    "iconLink": "https://ssl.gstatic.com/docs/doclist/images/icon_11_spreadsheet_list.png",
    "owners": [
        {
            "kind": "drive#user",
            "displayName": "***** *****",
            "isAuthenticatedUser": true,
            "permissionId": "*****************"
        }
    ],
    "lastModifyingUser": {
        "kind": "drive#user",
        "displayName": "*********",
        "isAuthenticatedUser": false,
        "permissionId": "*****************"
    },
    "copyable": true,
    "shared": true,
    "appDataContents": false
}

1 个答案:

答案 0 :(得分:0)

确保已实施正确的重试逻辑。见handling API errors。其中一些可能是短暂的问题。

该页面还讨论了特定错误代码的可能原因。例如,401可能表示您的令牌已过期。