Sends a file to one or more Elastic Compute Service (ECS) instances.
Usage notes
- The instances to which to send a file must be in the Running (
Running
) state. - Cloud Assistant Agent must be installed on the instances.
- Only Cloud Assistant Agent versions that are later than the following ones support file sending. If the
ClientNeedUpgrade
error code is returned, update Cloud Assistant Agent to the latest version.- For Linux instances, the version of Cloud Assistant Agent must be later than 1.0.2.569.
- For Windows instances, the version of Cloud Assistant Agent must be later than 1.0.0.149.
- The file that you want to send must not exceed 32 KB in size after it is encoded in Base64.
- The file may fail to be sent due to instance exceptions, network exceptions, or exceptions on Cloud Assistant Agent. Call the DescribeSendFileResults operation or see Check execution results and troubleshoot common issues for troubleshooting.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | SendFile | The operation that you want to perform. Set the value to SendFile. |
RegionId | String | Yes | cn-hangzhou | The region ID of the instance to which to send the file. You can call the DescribeRegions operation to query the most recent region list. |
ResourceGroupId | String | No | rg-bp67acfmxazb4p**** | The ID of the resource group. When you specify this parameter, take note of the following items:
|
Name | String | Yes | file.txt | The name of the file. The name supports all character sets and can be up to 255 characters in length. |
Description | String | No | This is a test file. | The description of the file. The description supports all character sets and can be up to 512 characters in length. |
Timeout | Long | No | 60 | The timeout period for the file sending task. Unit: seconds.
Default value: 60. |
TargetDir | String | Yes | /home | The destination directory on the instance to which to send the file. If the specified directory does not exist, the system creates the directory on the instance. The value supports all character sets and cannot exceed 255 characters in length. |
ContentType | String | No | PlainText | The content type of the file. Valid values:
Default value: PlainText. |
Content | String | Yes | #!/bin/bash echo "Current User is :" echo $(ps | grep "$$" | awk '{print $2}') -------- oss://bucketName/objectName | The content of the remote file. The content must not exceed 32 KB in size after it is encoded in Base64.
|
FileOwner | String | No | test | The owner of the file. This parameter takes effect only for Linux instances. Default value: root. The value can be up to 64 characters in length. Note If you want to use a non-root user, make sure that the user exists in the instances. |
FileGroup | String | No | test | The user group of the file. This parameter takes effect only for Linux instances. Default value: root. The user group name can be up to 64 characters in length. Note If you want to use a non-root user group, make sure that the user group exists in the instances. |
FileMode | String | No | 0644 | The permissions on the file. This parameter takes effect only for Linux instances. You can configure this parameter in the same way as you configure the chmod command. Default value: 0644, which indicates that the owner of the file has the read and write permissions on the file and that the user group of the file and other users have the read-only permissions on the file. |
Overwrite | Boolean | No | true | Specifies whether to overwrite a file in the destination directory if the file has the same name as the sent file.
Default value: false. |
InstanceId.N | String | Yes | i-bp185dy2o3o6n**** | The ID of instance N to which to send the file. Up to 50 instance IDs can be specified in each request. Valid values of N: 1 to 50. |
Tag.N.Key | String | No | TestKey | The key of tag N to add to the file sending task. Valid values of N: 1 to 20. The tag key cannot be an empty string. If a single tag is specified to query resources, up to 1,000 resources that have this tag added can be displayed in the response. If multiple tags are specified to query resources, up to 1,000 resources that have all these tags added can be displayed in the response. To query more than 1,000 resources that have specified tags, call the ListTagResources operation. The tag key can be up to 64 characters in length and cannot start with |
Tag.N.Value | String | No | TestValue | The value of tag N to add to the file sending task. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot contain |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
InvokeId | String | f-7d2a745b412b46**** | The file sending task ID. |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E | The request ID. |
Examples
Sample requests
https://ecs.aliyuncs.com/?Action=SendFile
&Content='echo hello'
&InstanceId.1=i-bp185dy2o3o6n****
&Name=file.txt
&RegionId=cn-hangzhou
&TargetDir=/home
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<SendFileResponse>
<RequestId>E69EF3CC-94CD-42E7-8926-F133B86387C0</RequestId>
<InvokeId>f-7d2a745b412b46****</InvokeId>
</SendFileResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "E69EF3CC-94CD-42E7-8926-F133B86387C0",
"InvokeId" : "f-7d2a745b412b46****"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | RegionId.ApiNotSupported | The api is not supported in this region. | This operation cannot be performed in the specified region. Check whether the region ID is valid. |
400 | MissingParam.InstanceId | The parameter instanceId is missing or empty. | InstanceId.N is required. |
400 | MissingParameter.TagKey | You must specify Tag.N.Key. | Tag.N.Key is required. |
400 | Duplicate.TagKey | The Tag.N.Key contain duplicate key. | The specified tag key already exists. Tag keys must be unique. |
400 | InvalidTagKey.Malformed | The specified Tag.n.Key is not valid. | Invalid Tag.N.Key value. |
400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | Invalid Tag.N.Value value. |
403 | FileSize.ExceedLimit | The length of file content exceeds limit. | The maximum file content length is exceeded. |
403 | FileName.ExceedLimit | The length of file name exceeds limit. | The maximum file name length is exceeded. |
403 | FileDesc.ExceedLimit | The length of file description exceeds limit. | The maximum file description length is exceeded. |
403 | FileTargetDir.Invalid | The target directory of file is invalid. | Invalid TargetDir value. |
403 | InstanceIds.ExceedLimit | The number of instance IDs exceeds the upper limit. | The maximum number of instance IDs is exceeded. |
403 | FileMode.Invalid | The mode of file is invalid. | Invalid FileMode value. |
403 | FileContent.DecodeError | The Content can not be base64 decoded. | The file content cannot be decoded in Base64. |
403 | FileContentType.Invalid | The ContentType of file is invalid. | Invalid ContentType value. |
403 | Operation.Forbidden | The operation is not permitted. | The operation is not supported. |
404 | InvalidInstance.NotFound | The specified instances not found. | The specified instances are not found. |
404 | InvalidResourceGroup.NotFound | The ResourceGroup provided does not exist in our records. | The resource group ID is not found. |
500 | InternalError.Dispatch | An error occurred when you dispatched the request. | An error occurred when the request was being sent. Try again later. |
For a list of error codes, see Service error codes.