简体   繁体   English

有没有办法从 Google Vault Export 下载导出的数据?

[英]Is there any way to download exported data from a Google Vault Export?

From documentation on https://developers.google.com/vault/guides/exports , I've been able to create, list, and retrieve exports, but I haven't found any way to download the exported data associated with a specific export.https://developers.google.com/vault/guides/exports 上的文档中,我已经能够创建、列出和检索导出,但我还没有找到任何方法来下载与特定关联的导出数据出口。 Is there any way to download the exported files via the API, or is this only available through the vault UI?有什么办法可以通过 API 下载导出的文件,还是只能通过 Vault UI 下载?

There is a cloudStorageSink key in the export metadata, but trying to use the values provided using the cloud storage API results in a generic permissions issue (403 Error).导出元数据中有一个cloudStorageSink键,但尝试使用通过云存储 API 提供的值会导致通用权限问题(403 错误)。

Example export metadata response:示例导出元数据响应:

{
    "status": "COMPLETED",
    "cloudStorageSink": {
        "files": [
            {
                "md5Hash": "da5e3979864d71d1e3ac776b618dcf48",
                "bucketName": "408d9135-6155-4a43-9d3c-424f124b9474",
                "objectName": "a740999b-e11b-4af5-b8b1-6c6def35d677/exportly-41dd7886-fe02-432f-83c-a4b6fd4520a5/Test_Export-1.zip",
                "size": "37720"
            },
            {
                "md5Hash": "d345a812e15cdae3b6277a0806668808",
                "bucketName": "408d9135-6155-4a43-9d3c-424f124b9474",
                "objectName": "a507999b-e11b-4af5-b8b1-6c6def35d677/exportly-41dd6886-fb02-4c2f-813c-a4b6fd4520a5/Test_Export-metadata.xml",
                "size": "8943"
            },
            {
                "md5Hash": "21e91e1c60e6c07490faaae30f8154fd",
                "bucketName": "408d9135-6155-4a43-9d3c-424f124b9474",
                "objectName": "a503959b-e11b-4af5-b8b1-6c6def35d677/exportly-41dd6786-fb02-42f-813c-a4b6fd4520a5/Test_Export-results-count.csv",
                "size": "26"
            }
        ]
    },
    "stats": {
        "sizeInBytes": "46689",
        "exportedArtifactCount": "7",
        "totalArtifactCount": "7"
    },
    "name": "Test Export",
    ...
}

There are two approaches that can do the action you require:有两种方法可以执行您需要的操作:

The first:首先:
using OAuth 2.0 refresh and access keys however it requires the intervention of the user, acknowledging your app access.使用 OAuth 2.0 刷新和访问密钥,但是它需要用户的干预,确认您的应用程序访问。 You can find a nice playground supplied by Google and more info here: https://developers.google.com/oauthplayground/ .您可以在此处找到 Google 提供的不错的游乐场以及更多信息: https : //developers.google.com/oauthplayground/

  1. You will first need to choose your desired API (in your case it is the: https://www.googleapis.com/auth/devstorage.full_controll under the Cloud Storage JSON API v1 section.您首先需要选择所需的 API(在您的情况下,它是: https://www.googleapis.com/auth/devstorage.full_controll : https://www.googleapis.com/auth/devstorage.full_controll ,位于Cloud Storage JSON API v1部分下。
  2. Then, you will need to log in with an admin account and click: "Exchange authorization code for tokens" (the fields "Refresh token" and "Access token" will be field automatically).然后,您需要使用管理员帐户登录并单击: “令牌的交换授权代码” (字段“刷新令牌”“访问令牌”将自动成为字段)。
  3. Lastly, you will need to choose the right URL to perform your request.最后,您需要选择正确的 URL 来执行您的请求。 I suggest using the "List possible operations" to choose the right URL.我建议使用“列出可能的操作”来选择正确的 URL。 You will need to choose "Get Object - Retrieve the object" under Cloud Storage API v1 (notice that there are several options with the name - "Get Object" , be sure to choose the one under Cloud Storage API v1 and not the one under Cloud Storage JSON API v1 ).您需要在Cloud Storage API v1下选择“Get Object - Retrieve the object” (注意有多个名称为“Get Object”的选项,请务必选择Cloud Storage API v1下的一个,而不是下一个云存储 JSON API v1 )。 Now just enter your bucket and object name in the appropriate placeholders and click Send the request .现在只需在适当的占位符中输入您的存储桶和对象名称,然后单击Send the request

The second:第二:
Programmatically download it using Google client libraries.使用 Google 客户端库以编程方式下载它。 This is the approach suggested by @darkfolcer however I believe that the documentation provided by Google is insufficient and thus does not really help.这是@darkfolcer建议的方法,但我认为 Google 提供的文档是不够的,因此并没有真正的帮助。 If a python example will help, you can find one in the answer to the following question - How to download files from Google Vault export immediately after creating it with Python API?如果 Python 示例会有所帮助,您可以在以下问题的答案中找到一个 - 如何在使用 Python API 创建文件后立即从 Google Vault 导出下载文件?

Once all the exports are created you'll need to wait for them to be completed.创建所有导出后,您需要等待它们完成。 You can use https://developers.google.com/vault/reference/rest/v1/matters.exports/list to check the status of every export in a matter.您可以使用https://developers.google.com/vault/reference/rest/v1/matters.exports/list检查事务中每个导出的状态。 In the response refer to the “exports” array and check the value of “status” for each, any that say "COMPLETED" can be downloaded.在响应中引用“exports”数组并检查每个“status”的值,任何说“COMPLETED”的都可以下载。

To download a completed export go to the “cloudStorageSink” object of each export and take the "bucketName" and "objectName" value of the first entry in the "files" Array.要下载完成的导出,请转到每个导出的“cloudStorageSink”对象,并获取“files”数组中第一个条目的“bucketName”和“objectName”值。 You'll need to use the Cloud Storage API and these two values to download the files.您需要使用 Cloud Storage API 和这两个值来下载文件。 This page has code examples for all the popular languages and using the API https://cloud.google.com/storage/docs/downloading-objects#storage-download-object-cpp .此页面包含所有流行语言和使用 API https://cloud.google.com/storage/docs/downloading-objects#storage-download-object-cpp 的代码示例。

Hope it helps.希望能帮助到你。

The issue you are seeing is because the API works with the principle of least privilege .您看到的问题是因为 API 使用了最低权限原则

The implications for you is that, since your objective is to download the files from the export, you would get the permissions to download only the files, not the whole bucket (even if it contains only those files).对您的影响是,由于您的目标是从导出中下载文件,您将获得仅下载文件的权限,而不是整个存储桶(即使它只包含这些文件)。

This is why when you request information from the storage bucket, you get the 403 error (permission error).这就是为什么当您从存储桶请求信息时,您会收到 403 错误(权限错误)。 However, you do have permission to download the files inside the bucket.但是,您确实有权下载存储桶中的文件。 In this way, what you should do is get each object directly , doing requests like this (using the information on the question):这样,你应该做的是 直接获取每个对象,做这样的请求(使用问题上的信息):

GET https://storage.googleapis.com/storage/v1/b/408d9135-6155-4a43-9d3c-424f124b9474/o/a740999b-e11b-4af5-b8b1-6c6def35d677/exportly-41dd7886-fe02-432f-83c-a4b6fd4520a5/Test_Export-1.zip

So, in short, instead of getting the full bucket, get each individual file generated by the export.因此,简而言之,不是获取完整存储桶,而是获取导出生成的每个单独文件。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Python API 创建文件后,如何立即从 Google Vault 导出下载文件? - How to download files from Google Vault export immediately after creating it with Python API? 从Filemaker导出数据的任何快速方法? - Any quick way to export data from Filemaker? 从 Google Vault API 导出查询结果时的 FAILD 状态 - FAILD status when export query result from Google Vault API 有没有办法使用 python 从 pardot 导出数据? - Is there any way to export data from pardot using python? 有没有可能使用python从pdf导出xml数据的方法 - is there any possible way to export xml data from a pdf using python 有什么方法可以通过 python 中的 url 的自定义查询下载数据? - any way to download the data with custom queries from url in python? 特定用户的Google Drive导出(Google保险柜) - Google Drive Export (Google Vault) for Specific User django 导入导出 | 未从数据库导出的数据 - django import_export | data not exported from database 有什么方法可以将数据从谷歌电子表格传递到 clickhouse? - Any way to deliver data from google spreadsheets to clickhouse? 有没有办法从某个页面下载音频 - Is there any way to download the audio from a certain page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM