> 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).

# 云存储

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

或者，我们也可以将结果上传到你的云存储。这样，你无需发起额外请求来获取结果——所有内容都会直接进入你的存储桶。

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

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

* [**Google Cloud Storage**](#google-cloud-storage)
* [**Amazon S3**](#amazon-s3)
* [**Alibaba Cloud Object Storage Service (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",
    "query": "https://example.com",
    "storage_type": "gcs",
    "storage_url": "bucket_name/path"
}
```

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

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

<div align="left"><img src="/files/0a169ed64253c085374ee4ffbe7e9971c8c7bc6c" alt=""></div>
{% endstep %}

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

<div align="left"><img src="/files/1a516f86ce7f76c30681823f2b0147aaad70c99b" alt=""></div>
{% endstep %}

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

在 **New members** 字段中，输入以下 **Oxylabs 服务账号电子邮件**:

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

<div align="left"><img src="/files/05f825aed9dc2a698562ade46da9835022cad400" alt=""></div>
{% endstep %}
{% endstepper %}

## **Amazon S3**

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

```json
{
    "source": "universal",
    "query": "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="/files/a85daea10b5984fdcdc7d8a2b1e524dbe1af5859" 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 Object Storage Service (OSS)

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

```json
{
    "source": "universal",
    "query": "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="/files/e8433d5b4e58afb43f17d9d60aa26fa61fc19cb4" alt=""><figcaption></figcaption></figure>

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

为了在 Alibaba Cloud 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 Account Menu**

<div align="left"><figure><img src="/files/81a4913122ae796ddde8107c9cbcec294bd736cc" alt="" width="422"><figcaption></figcaption></figure></div>
{% endstep %}

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

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

{% step %}
前往 **Identities** → **Users** （在左侧导航窗格中）
{% endstep %}

{% step %}
选择 **Create User** 并使用 **RAM User AccessKey：**

<div align="left"><figure><img src="/files/5d223d61dbb44b9bab154282ebc86e23dbb215fd" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="/files/8e7c5b0c96a83d57d7610404e6abacb3021e2725" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**向 RAM User 授予权限**

新创建的 RAM User 没有任何权限。你必须向 RAM User 授予 **AliyunOSSFullAccess** 权限。然后，RAM User 就可以访问所需的 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="/files/c11541442ed1a4ce4bc012b9b86147e2d72bfa75" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

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

授予权限后，返回 **Authentication** 部分，然后在 **Access Key** 部分中，选择 **Create AccessKey**。选择为 **Third-Party service**创建一个 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="/files/cfb3ab1998872f8887ada7e1d303e7c186445d3f" alt="" width="563"><figcaption></figcaption></figure></div>

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

## BytePlus TOS

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

要成功连接，你需要：

* 一个正确配置的 TOS 存储桶。
* 你的访问密钥和密钥。
* 一个兼容 S3 的端点。

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

### 示例

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

```json
{
    "source": "universal",
    "query": "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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
