> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kasoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# httpUpload

> 使用 multipart/form-data 发出 HTTP POST 请求，将文件上传到兼容 RFC 1867 的 API 接口。

使用 multipart/form-data 发出 HTTP POST 请求，将文件上传到兼容 <a href="https://www.rfc-editor.org/rfc/rfc1867" target="_blank">RFC 1867</a> 的 API 接口。

## 必需的参数

* **url**: POST 的目标 URL。
* **file:\***: 要上传的文件的路径。 该属性的格式必须在冒号后包含一个值和一个值参数（请参见下面的示例）。

## 可选的参数

* **authentication**: 用于设置手动生成的授权头，例如 bearer token。
* **authscheme**: 要使用的授权机制。仅当提供用户和密码时相关。允许的值为 `BASIC`、`DIGEST`、`NONE` 和 `NTLM`。默认值为 `BASIC`。
  * **user**: 如果 authscheme 参数设置为 `NONE` 以外的其它值，则使用该用户名进行身份验证。
  * **password**: 如果 authscheme 参数设置为 `NONE` 以外的其它值，则使用该密码进行身份验证。
* **charset**: 交换／传输的数据字符集。默认值为 `UTF-8`。
* **client\_id**: 客户端 ID。仅限 OAuth 1.0。
* **client\_secret**: 客户密钥。仅限 OAuth 1.0。
* **cookie:\***: 添加到请求中的 cookie。
* **filename:\***: 用于覆盖由 `file` 属性设置的表单数据的 `filename` 字段。
* **firewall\_port**: 防火墙的端口号。
* **firewall\_server**: 防火墙的 IP 地址或主机名。
  * **firewall\_user**: 向防火墙进行身份验证的用户 ID。
  * **firewall\_password**: 向防火墙进行身份验证的密码。
* **firewall\_type**: 防火墙的类型。允许的值为 `NONE`、`TUNNEL`、`SOCKS4` 和 `SOCKS5`。默认值为 `NONE`。
* **followredirects**: 是否遵循 HTTP 重定向。允许的值为 `TRUE` 或 `FALSE`。默认值是 `TRUE`。
* **form:\***: 表单输入变量数据包括在 POST 中。
* **header:name#**: 与请求一起传递的每个自定义头的名称。
* **header:value#**: 与请求一起传递的每个自定义头的值。
* **httpversion**: HTTP 协议版本。允许的值为 `1.0` 或 `1.1`。默认值为 `1.1`。
* **internalconfig#**: 设置一个内部配置设置。
* **name:\***: 用于覆盖由 `file` 属性设置的表单数据的 `name` 字段。
* **proxy\_authscheme**: 代理服务器的认证方案。允许的值为 `BASIC`、`DIGEST`、`PROPRIETARY`、`NONE` 和 `NTLM`。默认值为 `BASIC`。
* **proxy\_authtoken**: 代理身份验证令牌。
* **proxy\_auto**: 是否从 Windows 系统设置中检测代理。这优先于其它代理设置，在 Java 中不可用。允许的值为 `TRUE` 或 `FALSE`。默认值为 `FALSE`。
* **proxy\_port**: 代理服务器的端口号。
* **proxy\_server**: 代理服务器的 IP 地址或主机名。
  * **proxy\_user**: 向代理服务器进行身份验证的用户 ID。
  * **proxy\_password**: 与代理服务器进行身份验证的密码。
* **proxy\_ssltype**: 代理服务器的 TLS／SSL 类型。允许的值为 `AUTO`、`ALWAYS`、`NEVER` 和 `TUNNEL`。默认值为 `AUTO`。
* **sign\_method**: 计算 OAuth 1.0 签名的签名方法。允许的值为 `HMAC-SHA1` 和 `PLAINTEXT`。默认值为 `HMAC-SHA1`。
* **sslcert**: 要从服务器接受的 TLS／SSL 证书。这可以采用完整 PEM 证书，包含证书的文件路径，公钥，MD5 指纹或 SHA-1 指纹的形式。 指定证书以外的任何证书都将被拒绝。 如果未指定，此值默认为 `TRUSTED`，这意味着仅接受系统信任的证书。 如果设置为 `*`，则接受任何证书。
* **sslclientcert**: 客户端证书名称。
* **sslclientcertpassword**: 客户端证书的密码。
* **sslclientcertsubject**: 客户端证书的主题。使用星号会找到存储中的第一个证书。
* **sslclientcerttype**: 客户端证书的存储类型。允许的值为 `USER`、`MACHINE`、`PFXFILE`、`PFXBLOB`、`JKSFILE`、`JKSBLOB`、`PEMKEY\_FILE`、`PEMKEY\_BLOB`、`PUBLIC\_KEY\_FILE`、`PUBLIC\_KEY\_BLOB`、`SSHPUBLIC\_KEY\_BLOB`、`P7BFILE`、`P7BBLOB`、`SSHPUBLIC\_KEY\_FILE`、`PPKFILE`、`PPKBLOB`、`XMLFILE` 和 `XMLBLOB`。
* **timeout**: 操作完成的超时时间（以秒为单位）。零（0）表示没有超时。默认值为 `60`。
* **token**: OAuth 的请求令牌。
* **token\_secret**: 请求令牌密钥。仅限 OAuth 1.0。
* **version**: OAuth 版本。使用 OAuth 来授权请求。允许的值为 `Disabled`、`1.0` 和 `2.0`。默认值为 `Disabled`。

## 输出属性

* **cookie:\***: Cookie 随响应返回。
* **header:\***: 响应返回的头文件。
* **http:allcookies**: 响应中的所有 cookie，以单个字符串形式返回。
* **http:content**: HTTP 响应的内容。
* **http:statuscode**: 从请求返回的 HTTP 状态代码。
* **ssl:issuer**: TLS／SSL 证书的颁发者。
* **ssl:subject**: TLS／SSL 证书的主题。

## 示例

```xml theme={null}
<!-- Setting the url and upload file for the request -->
<arc:set attr="http.URL" value="https://postman-echo.com/post" />
<arc:set attr="http.file:myfile" value="[FilePath]" />
<!-- Overriding the name and filename attribute on the request -->
<arc:set attr="http.name:myfile" value="myNewFile" />
<arc:set attr="http.filename:myfile" value="customFilename.txt" />
<!-- Setting additional form data on the request -->
<arc:set attr="http.form:hello" value="world" />
<arc:set attr="http.form:foo" value="bar" />
<!-- Adding an HTTP header to the request -->
<arc:set attr="http.header:name#1" value="mySpecialHeader" />
<arc:set attr="http.header:value#1"value="Foo" />
<!-- Setting the credentials via basic authentication -->
<arc:set attr="http.user" value="postman" />
<arc:set attr="http.password" value="password" />
<!-- Optional logging parameter. Useful when troubleshooting a request -->
<arc:set attr="http.logfile" value="/tmp/httpLog.txt" />
<arc:set attr="http.verbosity" value="3" />

<!-- Passing in the http input item to the call and setting the data of the output file to be the HTTP response -->
<arc:call op="httpUpload" in="http" out="response">
  <arc:set attr="output.data" value="[response.http:content]" />
</arc:call>

<!-- Setting the output filename and pushing the file out -->
<arc:set attr="output.filename" value="httpResponseContent.txt" />
<arc:push item="output" />
```
