> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/web-scraper-api/features/result-processing-and-storage/cloud-storage.md).

# 云存储

将抓取结果直接检索至您的 S3、GCS、OSS 或其他兼容 S3 的存储。

网页爬虫API 作业结果存储在我们的存储中。您可以通过以下方式从我们的存储中获取结果： `GET`获取 `/results` 端点。

作为替代方案，我们可以将结果上传到您的云存储。这样，您无需额外请求来获取结果——所有内容都会直接进入您的存储桶。

{% hint style="info" %}
云存储集成仅适用于 [**Push-Pull**](https://developers.oxylabs.io/products/cn/web-scraper-api/integration-methods/push-pull.md) 集成方式。
{% endhint %}

目前，我们支持以下云存储服务：

* [**Google Cloud Storage**](#google-cloud-storage)
* [**Amazon S3**](#amazon-s3)
* [**Alibaba Cloud 对象存储服务（OSS）**](#alibaba-cloud-object-storage-service-oss)
* [**BytePlus Torch Object Storage (TOS)**](#byteplus-tos)
* [**其他兼容 S3 的存储**](#other-s3-compatible-storage)

如果您想使用其他类型的存储，请联系您的客户经理，讨论功能交付时间线。

上传路径如下： `YOUR_BUCKET_NAME/job_ID.json`。您会在提交作业后收到的响应中找到作业 ID。

#### 输入

<table><thead><tr><th>参数</th><th width="187.33333333333331">说明</th><th>有效值</th></tr></thead><tbody><tr><td><code>storage_type</code></td><td>您的云存储类型。</td><td><p><code>gcs</code> (Google Cloud Storage);</p><p><code>s3</code> (AWS S3); <code>tos</code> (BytePlus TOS);</p><p><code>s3_compatible</code> (任何兼容 S3 的存储)。</p></td></tr><tr><td><code>storage_url</code></td><td>您的云存储存储桶名称 / URL。</td><td><ul><li>任意 <code>s3</code> , <code>gcs</code> ，或 <code>tos</code> 存储桶名称；</li><li>任意 <code>兼容 S3</code> 存储 URL。</li></ul></td></tr></tbody></table>

## **Google Cloud Storage**

下面的载荷将使网页爬虫API抓取 `https://example.com` 并将结果放入 Google Cloud Storage 存储桶。

```json
{
    "source": "universal",
    "url": "https://example.com",
    "storage_type": "gcs",
    "storage_url": "bucket_name/path"
}
```

要将作业结果上传到您的 Google Cloud Storage 存储桶，请按如下所示为我们的服务设置特殊权限：

{% stepper %}
{% step %}
**创建自定义角色**

<div align="left"><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-32292235b253d2435d5e0a8d88558c068872956d%2Fgcs-1.png?alt=media" alt=""></div>
{% endstep %}

{% step %}
**添加 `storage.objects.create` 权限**

<div align="left"><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-815bad910c08ed706d3df43ddb20fff0f0563d6d%2Fgcs-2.png?alt=media" alt=""></div>
{% endstep %}

{% step %}
**将其分配给 Oxylabs**

在 **新成员** 字段中，输入以下 **Oxylabs 服务账户邮箱**:

```
oxyserps-storage@oxyserps-storage.iam.gserviceaccount.com
```

<div align="left"><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-df5b74908cc6943c8d620b5e14487f2d003ebe43%2Fgcs-3.png?alt=media" alt=""></div>
{% endstep %}
{% endstepper %}

## **Amazon S3**

下面的载荷将使网页爬虫API抓取 `https://example.com` 并将结果放入 Amazon S3 存储桶。

```json
{
    "source": "universal",
    "url": "https://example.com",
    "storage_type": "s3",
    "storage_url": "bucket_name/path"
}
```

要将作业结果上传到您的 Amazon S3 存储桶，请为我们的服务设置访问权限。为此，请前往 [**https://s3.console.aws.amazon.com/**](https://s3.console.aws.amazon.com/) → **`S3`** → **`存储`** → **`存储桶名称`**` `` ``（如果您没有，请创建一个新的） ` → **`权限`** → **`存储桶策略`**.

<div align="left"><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-1c27676a6e925e4a8c257cf422e991c8a6a1af2c%2Fs3_bucket_policy.png?alt=media" alt=""></div>

您可以在下面的附件或代码示例区域中找到存储桶策略。

{% file src="/files/613dde66c560f9f6d82fc2197d93ed7699fd0ddf" %}
s3 存储桶策略
{% endfile %}

不要忘记修改下方的存储桶名称 `YOUR_BUCKET_NAME`。此策略允许我们向您的存储桶写入，为您提供对已上传文件的访问权限，并知道存储桶位置。

```json
{
    "Version": "2012-10-17",
    "Id": "Policy1577442634787",
    "Statement": [
        {
            "Sid": "Stmt1577442633719",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::324311890426:user/oxylabs.s3.uploader"
            },
            "Action": "s3:GetBucketLocation",
            "Resource": "arn:aws:s3:::YOUR_BUCKET_NAME"
        },
        {
            "Sid": "Stmt1577442633719",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::324311890426:user/oxylabs.s3.uploader"
            },
            "Action": [
                "s3:PutObject",
                "s3:PutObjectAcl"
            ],
            "Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*"
        }
    ]
}
```

## Alibaba Cloud 对象存储服务（OSS）

下面的载荷将使网页爬虫API抓取 `https://example.com` 并将结果放入 Alibaba Cloud OSS 存储桶。

```json
{
    "source": "universal",
    "url": "https://example.com",
    "storage_type": "s3_compatible",
    "storage_url": "https://ACCESS_KEY_ID:ACCESS_KEY_SECRET@BUCKET_NAME.oss-REGION.aliyuncs.com/FOLDER_NAME"
}
```

### 构建存储 URL <a href="#forming-the-storage-url" id="forming-the-storage-url"></a>

存储 URL 格式：

```http
https://ACCESS_KEY_ID:ACCESS_KEY_SECRET@BUCKET_NAME.oss-REGION.aliyuncs.com/FOLDER_NAME
```

{% hint style="warning" %}
目前， **我们无法上传到根存储桶**。请为您的上传提供一个具体的文件夹名称。
{% endhint %}

以下是您可以找到 `BUCKET_NAME` 和 `oss-REGION` 的存储桶位置：

<figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-3258197766d6326f572b9230603b3f700738db36%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### 创建 Access Key 和 Secret <a href="#creating-the-access-key-and-secret" id="creating-the-access-key-and-secret"></a>

为了使用 Alibaba OSS 的 S3 兼容接口，您必须创建 `ACCESS_KEY_ID` 和 `ACCESS_KEY_SECRET` ，如下所示。更多信息请参见 [![](https://img.alicdn.com/tfs/TB1ugg7M9zqK1RjSZPxXXc4tVXa-32-32.png)如何使用 Amazon S3 SDK 访问 OSS](https://www.alibabacloud.com/help/en/oss/developer-reference/use-amazon-s3-sdks-to-access-oss?spm=a2c63.p38356.0.i1).

{% stepper %}
{% step %}
转到 **AccessKey 账户菜单**

<div align="left"><figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-7a0c00eac6fd02fed28c7be5a5522985de3625d5%2Fimage.png?alt=media" alt="" width="422"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
登录到 **RAM console**

访问 [RAM console](https://ram.console.aliyun.com/) 通过 **Alibaba Cloud 账户** 或 **RAM 用户** ，且具有管理员权限。
{% endstep %}

{% step %}
转到 **身份** → **用户** 在左侧导航窗格中
{% endstep %}

{% step %}
选择 **创建用户** 并使用 **RAM User AccessKey:**

<div align="left"><figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-e06b15f92c10028d2f5c368321821a90abf01f3f%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-4103046af7ce401cd189cd53f238fddf41b64ab5%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**向 RAM 用户授予权限**

新创建的 RAM 用户没有权限。您必须向 RAM 用户授予 **AliyunOSSFullAccess** 权限。然后，RAM 用户即可访问所需的 Alibaba Cloud 资源。更多信息请参见 [向 RAM 用户授予权限](https://www.alibabacloud.com/help/en/ram/user-guide/grant-permissions-to-the-ram-user#task-187800).

<div align="left"><figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-6d76a9af42bd9f8eaabdbee6c4baadd5824a0a09%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
获取您的 **AccessKey ID** 和 **AccessKey Secret**

授予权限后，返回到 **身份验证** 部分，并在 **Access Key** 部分中，选择 **创建 AccessKey**。选择为 **第三方服务**创建 Access Key。然后，您会看到一个 `ACCESS_KEY_ID` 和 `ACCESS_KEY_SECRET`，随后可在请求中使用它。
{% endstep %}
{% endstepper %}

### Alibaba OSS 速率限制 <a href="#alibaba-oss-ratelimits" id="alibaba-oss-ratelimits"></a>

当并发上传到 Alibaba OSS 时，可能会触及其账户/存储桶速率限制，上传将开始因以下错误而超时：

<div align="left"><figure><img src="https://3714446197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-8c6734c7968642444e43843fb1f200f0ab739c81%2Fimage.png?alt=media" alt="" width="563"><figcaption></figcaption></figure></div>

在这种情况下，请联系 Alibaba OSS 支持以提高您的 OSS 速率限制。

## BytePlus TOS

您可以直接将抓取结果上传到 BytePlus Torch Object Storage (TOS) 存储桶。

成功连接需要：

* 配置正确的 TOS 存储桶。
* 您的 access key 和 secret key。
* 兼容 S3 的端点。

您可以在官方 BytePlus 的 [文档](https://docs.byteplus.com/en/docs/tos/docs-region-and-endpoint).

### 示例

下面的载荷将抓取 `https://example.com` 并将结果上传到您的 TOS 存储桶。

```json
{
    "source": "universal",
    "url": "https://example.com",
    "storage_type": "tos",
    "storage_url": "https://access_key:secret_key@endpoint/bucket_name/path"
}
```

### 参数 <a href="#docs-internal-guid-dbfc45c7-7fff-9754-b71a-bacb24e2ac54" id="docs-internal-guid-dbfc45c7-7fff-9754-b71a-bacb24e2ac54"></a>

<table><thead><tr><th width="166">参数</th><th width="165">可用值</th><th>说明</th></tr></thead><tbody><tr><td><code>storage_type</code></td><td><code>tos</code></td><td>指定 BytePlus TOS 作为存储提供商。</td></tr><tr><td><code>storage_url</code></td><td>URL 字符串</td><td>用于访问您的 TOS 存储桶的已认证 URL（格式见下文）。</td></tr></tbody></table>

### 存储 URL 格式

该 `storage_url` 必须使用您的 TOS 凭证和存储桶详细信息构造。

```bash
https://access_key:secret_key@endpoint/bucket_name/path
```

| 组件            | 说明                                             |
| ------------- | ---------------------------------------------- |
| `access_key`  | 您的 BytePlus access key ID。                     |
| `secret_key`  | 您的 BytePlus secret access key。                 |
| `endpoint`    | 特定区域的端点（例如， `tos-cn-hongkong.bytepluses.com`). |
| `bucket_name` | 目标存储桶名称。                                       |
| `path`        | *（可选）* 存储桶的特定文件夹路径。                            |

{% hint style="warning" %}
如果您的 Access Key 或 Secret Key 包含特殊字符（例如 `/`, `+`，或 `=`），则它们 **必须进行 URL 编码** 后再构造字符串。
{% endhint %}

### 输出文件命名

Oxylabs 会根据作业详情自动为上传的对象生成文件名：

* **HTML/内容：** `{query_id}_{timestamp}.html`
* **解析后的数据：** `{query_id}_results.json`

文件可在您的存储桶中的以下位置访问： `tos://{bucket_name}/{path}/{filename}`

## 其他兼容 S3 的存储

如果您希望将结果交付到兼容 S3 的存储位置，则需要在您的存储桶 `ACCESS_KEY:SECRET` 认证字符串中包含 `storage_url` 值：

```json
{
    "source": "universal",
    "url": "https://example.com",
    "storage_type": "s3_compatible",
    "storage_url": "https://ACCESS_KEY:SECRET@s3.oxylabs.io/my-videos"
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.oxylabs.io/products/cn/web-scraper-api/features/result-processing-and-storage/cloud-storage.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
