调用SendFile向一台或多台ECS实例下发远程文件。
接口说明
接口说明
目标 ECS 实例的状态必须为运行中(
Running)。目标 ECS 实例必须预先安装云助手 Agent。
- 云助手 Agent 版本需要高于以下对应的版本才能支持下发文件。如果结果返回
ClientNeedUpgrade错误码,请将客户端更新至最新版本。Linux:1.0.2.569
Windows:1.0.0.149
文件内容在进行 Base64 编码后,大小不能超过 32 KB。
文件下发可能会因为目标 ECS 实例的状态异常、网络异常或云助手 Agent 异常而出现失败的情况。请调用 DescribeSendFileResults ,或参考执行失败常见错误及修复建议进行问题排查。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
ecs:SendFile |
update |
*Instance
|
无 | 无 |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| RegionId |
string |
是 |
目标 ECS 实例所在的地域 ID。您可以调用 DescribeRegions 查看最新的阿里云地域列表。 |
cn-hangzhou |
| ResourceGroupId |
string |
否 |
文件下发的资源组 ID,当指定该参数时:
|
rg-bp67acfmxazb4p**** |
| RegionId |
string |
是 |
目标 ECS 实例所在的地域 ID。您可以调用 DescribeRegions 查看最新的阿里云地域列表。 |
cn-hangzhou |
| Name |
string |
是 |
文件名称。支持全字符集,长度不得超过 255 个字符。 |
file.txt |
| Description |
string |
否 |
描述信息。支持全字符集,长度不得超过 512 个字符。 |
This is a test file. |
| Timeout |
integer |
否 |
下发文件的超时时间。单位:秒。
默认值为 60。 |
60 |
| TargetDir |
string |
是 |
文件下发目标 ECS 实例中的目录。如不存在则会自动创建。长度不得超过 255 个字符。 |
/home |
| ContentType |
string |
否 |
文件内容类型。
默认值为 PlainText。 |
PlainText |
| Content |
string |
是 |
文件内容。文件内容在 Base64 编码后,大小不能超过 32 KB。
|
#!/bin/bash echo "Current User is :" echo $(ps | grep "$$" | awk '{print $2}') -------- oss://bucketName/objectName |
| FileOwner |
string |
否 |
文件的用户。只对 Linux 实例生效,默认为 root。长度不得超过 64 个字符。 说明
使用其他用户时,请确保实例中存在该用户。 |
test |
| FileGroup |
string |
否 |
文件的用户组。只对 Linux 实例生效,默认为 root。长度不得超过 64 个字符。 说明
使用其他用户组时,请确保实例中存在该用户组。 |
test |
| FileMode |
string |
否 |
文件的权限。只对 Linux 实例生效,设置方式与 chmod 命令相同。 默认值为 0644,表示用户具有读写权限,用户组和其它用户具有只读权限。 |
0644 |
| Overwrite |
boolean |
否 |
如果同名文件在目标目录已存在,是否覆盖文件。
默认值为 false。 |
true |
| ClientToken |
string |
否 |
保证请求幂等性。从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符,且不能超过 64 个字符。更多信息,请参见如何保证幂等性。 |
123e4567-e89b-12d3-a456-426655440000 |
| InstanceId |
array |
是 |
需要执行命令的 ECS 实例列表。最多能指定 50 台 ECS 实例 ID。N 的取值范围为 1~50。 |
i-bp185dy2o3o6n**** |
|
string |
否 |
需要执行命令的 ECS 实例列表。最多能指定 50 台 ECS 实例 ID。N 的取值范围为 1~50。 |
i-bp185dy2o3o6n**** |
|
| Tag |
array<object> |
否 |
标签列表。 |
|
|
object |
否 |
标签列表。 |
||
| Key |
string |
否 |
文件下发的标签键。N 的取值范围为 1~20。一旦传入该值,则不允许为空字符串。 使用一个标签过滤资源,查询到该标签下的资源数量不能超过 1000 个。使用多个标签过滤资源,查询到同时绑定了多个标签的资源数量不能超过 1000 个。如果资源数量超过 1000 个,您需要使用 ListTagResources 接口进行查询。 最多支持 64 个字符,不能以 |
TestKey |
| Value |
string |
否 |
文件下发的标签值。N 的取值范围为 1~20。该值可以为空字符串。 最多支持 128 个字符,不能包含 |
TestValue |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
|||
| InvokeId |
string |
命令执行 ID。 |
f-7d2a745b412b46**** |
| RequestId |
string |
请求 ID。 |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E |
示例
正常返回示例
JSON格式
{
"InvokeId": "f-7d2a745b412b46****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 400 | RegionId.ApiNotSupported | The api is not supported in this region. | 指定地域下不支持调用 API。请检查 RegionId 参数取值是否正确。 |
| 400 | MissingParam.InstanceId | The parameter instanceId is missing or empty. | 实例ID为空。 |
| 400 | NumberExceed.Tags | The Tags parameter number is exceed. | 标签个数超过最大限制。 |
| 400 | MissingParameter.TagKey | You must specify Tag.N.Key. | 请指定标签键。 |
| 400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | 标签中存在重复的键,请保持键的唯一性。 |
| 400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | 指定的标签键参数有误。 |
| 400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | 指定的标签值参数有误。 |
| 400 | FileTargetDir.Invalid | The target directory of file is invalid. | |
| 400 | FileMode.Invalid | The mode of file is invalid. | |
| 400 | FileContent.DecodeError | The Content can not be base64 decoded. | |
| 400 | FileContentType.Invalid | The ContentType of file is invalid. | |
| 400 | InvalidParameter.FileOwner | The specified parameter FileOwner is not valid. | 指定的参数FileOwner不合法。 |
| 400 | InvalidParameter.FileGroup | The specified parameter FileGroup is not valid. | 指定的参数FileGroup不合法。 |
| 400 | InvalidClientToken.Malformed | The specified parameter clientToken is not valid. | 指定的幂等参数不合法。 |
| 500 | InternalError.Dispatch | An error occurred when you dispatched the request. | 发送请求时发生错误,请稍后重试。 |
| 403 | FileSize.ExceedLimit | The length of file content exceeds limit. | 文件内容长度超过上限。 |
| 403 | FileName.ExceedLimit | The length of file name exceeds limit. | 文件名称长度超过上限。 |
| 403 | FileDesc.ExceedLimit | The length of file description exceeds limit. | 文件描述长度超过上限。 |
| 403 | InstanceIds.ExceedLimit | The number of instance IDs exceeds the upper limit. | 目标实例数量超过上限。 |
| 403 | Operation.Forbidden | The operation is not permitted. | 该操作是不被允许的。 |
| 403 | InvalidTimeout.ExceedLimit | The specified parameter Timeout exceeds the upper limit. | |
| 403 | IdempotentParameterMismatch | The specified parameter has changed while using an already used clientToken. | 指定的客户令牌已经被使用。 |
| 403 | IdempotentProcessing | The previous idempotent request(s) is still processing. | 先前的幂等请求仍在处理中,请稍后重试。 |
| 404 | InvalidRegionId.NotFound | The RegionId provided does not exist in our records. | 地域信息错误 |
| 404 | InvalidInstance.NotFound | The specified instances not found. | 指定的实例ID不存在。 |
| 404 | InvalidResourceGroup.NotFound | The ResourceGroup provided does not exist in our records. | 资源组并不在记录中。 |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。