Orchestrator
最新
False
横幅背景图像
Orchestrator API 指南
上次更新日期 2024年4月24日

储存桶要求

将文件添加到存储桶

使用 Orchestrator API 将文件上传到现有存储桶是一个两部分流程:

  • 首先,您需要调用 GET /odata/Buckets({key})/UiPath.Server.Configuration.OData.GetWriteUri 端点,该端点会返回 URI 和 HTTP 方法作为响应。
  • 然后,您需要使用 GET 响应中的 HTTP 方法调用 {URI} 端点,以二进制格式附加要上传的文件,并将其发送到从 GET 请求获取的 URI。

GET 端点

获取 https://cloud.uipath.com/{organizationName}/{tenantName}/orchestrator_/odata/Buckets({key})/UiPath.Server.Configuration.OData.GetWriteUri
要查找 URI 和 HTTP 谓词,您需要将文件上传到现有存储桶,然后向 /odata/Buckets({key})/UiPath.Server.Configuration.OData.GetWriteUri 发出 GET 请求。

提供以下参数和标头:

路径参数

路径参数

数据类型

描述

key

(必填)

字符串

要上传文件的存储桶 ID。

查询参数

参数

数据类型

描述

path

(必填)

字符串

要上传的文件名称及其扩展名。

例如,“my_file.txt”。

contentType

(必填)

字符串

文件扩展名的内容类型。

例如,.txt 扩展程序的内容类型为 text/plain

请求标头

--header 'Authorization: Bearer {access_token}'\
--header 'Content-Type: application/json' \
--header 'X-UIPATH-OrganizationUnitId: {the_ID_of_the_folder_that_contains_the_storage_bucket}' \--header 'Authorization: Bearer {access_token}'\
--header 'Content-Type: application/json' \
--header 'X-UIPATH-OrganizationUnitId: {the_ID_of_the_folder_that_contains_the_storage_bucket}' \
X-UIPATH-OrganizationUnitId 是包含存储桶的文件夹的 ID。

请求示例

curl --location --request GET 'https://cloud.uipath.com/{organizationName}/{tenantName}/orchestrator_/odata/Buckets(28053)/UiPath.Server.Configuration.OData.GetWriteUri?path=my_file.txt&contentType=text/plain' \
--header 'x-uipath-organizationunitid: 3991326' \
--header 'Authorization: Bearer 1234'curl --location --request GET 'https://cloud.uipath.com/{organizationName}/{tenantName}/orchestrator_/odata/Buckets(28053)/UiPath.Server.Configuration.OData.GetWriteUri?path=my_file.txt&contentType=text/plain' \
--header 'x-uipath-organizationunitid: 3991326' \
--header 'Authorization: Bearer 1234'
出于长度方面的考虑,示例中的访问令牌为 1234

响应正文

响应正文包含以二进制格式将文件上传到存储桶所需的 URI 和 HTTP 谓词。

{
    "@odata.context": "https://cloud.uipath.com/{organizationName}/{tenantName}/orchestrator_/odata/$metadata#UiPath.Server.Configuration.OData.BlobFileAccessDto",
    "Uri": "https://cr.blob.core.windows.net/orchestrator-4871-905f/BlobFilePersistence/2760e0fe-0fa7/my_file.txt?sv=2021-08-06&st=2023-01-13T16%3A32%3A12Z&se=2023-01-13T17%3A32%3A42Z&sr=b&sp=cw&sig=xB3W02xGYHfw%3D",
    "Verb": "PUT",
    "Headers": {
        "Keys": [
            "x-ms-blob-type"
        ],
        "Values": [
            "BlockBlob"
        ]
    }
}{
    "@odata.context": "https://cloud.uipath.com/{organizationName}/{tenantName}/orchestrator_/odata/$metadata#UiPath.Server.Configuration.OData.BlobFileAccessDto",
    "Uri": "https://cr.blob.core.windows.net/orchestrator-4871-905f/BlobFilePersistence/2760e0fe-0fa7/my_file.txt?sv=2021-08-06&st=2023-01-13T16%3A32%3A12Z&se=2023-01-13T17%3A32%3A42Z&sr=b&sp=cw&sig=xB3W02xGYHfw%3D",
    "Verb": "PUT",
    "Headers": {
        "Keys": [
            "x-ms-blob-type"
        ],
        "Values": [
            "BlockBlob"
        ]
    }
}

PUT 端点

放置 {URI}

URI 是响应正文中“Uri”键的值。

请求标头

--header 'x-ms-blob-type: BlockBlob' \
--header 'Content-Type: text/plain'--header 'x-ms-blob-type: BlockBlob' \
--header 'Content-Type: text/plain'
备注:
  • 确保在 GET 响应正文中包含收到的标头,并为其分配值。例如,对于 Azure Blob 存储,返回的标头为 x-ms-blob-type-header,它使用 BlockBlob 值。
  • 请勿在此请求中使用授权标头。

请求正文

以二进制格式上传文件。您必须使用在 GET 请求中用作查询参数的同一文件。在本例中,为“my_file.txt”。

--data-binary '@/C:/Users/adam.eve/OneDrive/Documents/my_file.txt'--data-binary '@/C:/Users/adam.eve/OneDrive/Documents/my_file.txt'

请求示例

假设您收集了构建 API 调用所需的所有信息。

curl --location --request PUT 'https://cr.blob.core.windows.net/orchestrator-4871-905f/BlobFilePersistence/2760e0fe-0fa7/my_file.txt?sv=2021-08-06&st=2023-01-13T16%3A32%3A12Z&se=2023-01-13T17%3A32%3A42Z&sr=b&sp=cw&sig=xB3W02xGYHfw%3D' \
--header 'x-ms-blob-type: BlockBlob' \
--header 'Content-Type: text/plain' \
--data-binary '@/C:/Users/adam.eve/OneDrive/Documents/my_file.txt'curl --location --request PUT 'https://cr.blob.core.windows.net/orchestrator-4871-905f/BlobFilePersistence/2760e0fe-0fa7/my_file.txt?sv=2021-08-06&st=2023-01-13T16%3A32%3A12Z&se=2023-01-13T17%3A32%3A42Z&sr=b&sp=cw&sig=xB3W02xGYHfw%3D' \
--header 'x-ms-blob-type: BlockBlob' \
--header 'Content-Type: text/plain' \
--data-binary '@/C:/Users/adam.eve/OneDrive/Documents/my_file.txt'

在 Orchestrator 用户界面中,该文件在您的存储桶中可见。

此页面是否有帮助?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath 白色徽标
信任与安全
© 2005-2024 UiPath. All rights reserved.