> For the complete documentation index, see [llms.txt](https://testindata.gitbook.io/dataset/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://testindata.gitbook.io/dataset/python-sdk/shang-chuan-wen-jian-1.md).

# 上传文件

通过上一节学习了SDK的初始化，我们得到了一个用于全局操作的TDA对象，我们可以使用该对象来实现对文件的上传操作。

### 添加文件

在使用授权云存储管理您的数据集文件时，可以使用本方法上传文件

```bash
file = tda.AddFile(filePath, objectName="", referId="", metaData={}, sensor="", frameId="")
```

| 参数         | 类型           | 必填 | 说明                                                                               |
| ---------- | ------------ | -- | -------------------------------------------------------------------------------- |
| filePath   | string       | 是  | 添加文件的绝对路径                                                                        |
| objectName | string       | 否  | 上传至数据集之后的OSS存储对象名称                                                               |
| referId    | string       | 否  | 系统内用ref\_id表示，您自行维护的**唯一**定位该文件的业务id，同一数据集如果传入多个相同的ref\_id，按该字段检索时仅会返回第一个符合要求的结果 |
| metaData   | dict         | 否  | 有关于图片本身的一些信息，诸如：天气，场景，来源等等                                                       |
| sensor     | string(enum) | 否  | **点云融合类型的数据集此项为必填**，填入的值为枚举值，pointcloud为点云，camera\_0 至 camera\_9为相机              |
| frameId    | string       | 否  | **点云融合类型的数据集此项为必填**，用于关联不同传感器的可视化，最大长度64                                         |

返回值为云测数据集管理系统SDK File 对象。您可以使用循环一次性将所有想要上传的文件添加到TDA中。

### 添加URL文件

在选用自有存储管理您的数据集文件时，您需要用此方法添加您已有的文件访问URL

```bash
file = tda.AddUrlFile(url, referId="", metaData={}, sensor="", frameId="", filename="", md5="", filesize=0)
```

| 参数         | 类型           | 必填 | 说明                                                                               |
| ---------- | ------------ | -- | -------------------------------------------------------------------------------- |
| url        | string       | 是  | 添加文件的访问                                                                          |
| objectName | string       | 否  | 上传至数据集之后的OSS存储对象名称                                                               |
| referId    | string       | 否  | 系统内用ref\_id表示，您自行维护的**唯一**定位该文件的业务id，同一数据集如果传入多个相同的ref\_id，按该字段检索时仅会返回第一个符合要求的结果 |
| metaData   | dict         | 否  | 有关于图片本身的一些信息，诸如：天气，场景，来源等等                                                       |
| sensor     | string(enum) | 否  | **点云融合类型的数据集此项为必填**，填入的值为枚举值，pointcloud为点云，camera\_0 至 camera\_9为相机              |
| frameId    | string       | 否  | **点云融合类型的数据集此项为必填**，用于关联不同传感器的可视化，最大长度64                                         |

返回值为云测数据集管理系统SDK File 对象。您可以使用循环一次性将所有想要上传的文件添加到TDA中。

###

### 上传文件

添加好文件之后，执行使用以下方法将文件上传至您设置好的OSS存储中，并将数据信息同步到数据集管理系统。

```bash
print(tda.Upload(overlay=False, commitId = ""))
```

| 参数       | 类型     | 必填 | 说明                                                                                                                                                                                                                |
| -------- | ------ | -- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| overlay  | bool   | 否  | 默认为False，即以跳过上传的方式执行。本参数用于控制上传文件至OSS时是否要以覆盖的方式上传，实际上传过程中难免会由于种种原因导致上传中断，中断之后原先上传过的文件可以略过，如果您确实对上传的文件做了变更，比如改变了图片的尺寸等，则可以将本参数设置为True，SDK将会再次上传该文件。这里提到的已经上传过的文件应理解为：**同一数据集ID下，文件原始路径和上传至OSS的目标路径与上一次上传时完全一致的文件。** |
| commitId | string | 否  | 每次数据整理完成后会将整理的数据缓存起来，并为该缓存分配一个随机的id，该id可以通过debug信息看到。如果您已经整理好了数据，准备再次上传时，可以通过设置本id上传已经整理好的数据，而无须再次进行Addfile和相关的操作。                                                                                                |

返回值为一个dict，信息包括成功了的数量和失败了的数量。


---

# 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, and the optional `goal` query parameter:

```
GET https://testindata.gitbook.io/dataset/python-sdk/shang-chuan-wen-jian-1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
