All Products
Search
Document Center

Elastic Compute Service:SendFile

Last Updated:Jul 29, 2026

Sends a remote file to one or more ECS instances.

Operation description

Operation description

  • The target ECS instances must be in the running state.

  • Cloud Assistant Agent must be installed on the target ECS instances. For more information, see Cloud Assistant Agent.

  • The Cloud Assistant Agent version must be later than the following versions to support file sending. If the ClientNeedUpgrade error code is returned, update the agent to the latest version.
    • Linux: 1.0.2.569

    • Windows: 1.0.0.149

  • The file content cannot exceed 32 KB after Base64 encoding.

  • File sending may fail due to exceptions in the target ECS instance status, network issues, or Cloud Assistant Agent exceptions. Call DescribeSendFileResults or refer to Common errors and solutions for execution failures to troubleshoot issues.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:SendFile

update

*Instance

acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the target ECS instances. You can call DescribeRegions to query the most recent region list.

cn-hangzhou

ResourceGroupId

string

No

The ID of the resource group for file sending. If you specify this parameter:

  • The ECS instances specified by InstanceId must belong to this resource group.

  • You can filter file sending results by specifying this parameter when you call DescribeSendFileResults.

rg-bp67acfmxazb4p****

Name

string

Yes

The name of the file. The full character set is supported. The name cannot exceed 255 characters in length.

file.txt

Description

string

No

The description of the file. The full character set is supported. The description cannot exceed 512 characters in length.

This is a test file.

Timeout

integer

No

The timeout period for sending the file. Unit: seconds.

  • A timeout may occur when the file cannot be sent due to a process issue, a missing module, or a missing Cloud Assistant Agent.

  • If the specified timeout period is less than 10 seconds, the system automatically sets the timeout period to 10 seconds to ensure successful delivery.

Default value: 60.

60

TargetDir

string

Yes

The destination directory on the target ECS instances where the file is sent. If the directory does not exist, it is automatically created. The directory path cannot exceed 255 characters in length.

/home

ContentType

string

No

The content type of the file. Valid values:

  • PlainText: plain text.

  • Base64: Base64-encoded.

Default value: PlainText.

PlainText

Content

string

Yes

The content of the file. The file content cannot exceed 32 KB after Base64 encoding.

  • If ContentType is set to PlainText, this parameter specifies the plain text content.

  • If ContentType is set to Base64, this parameter specifies the Base64-encoded content.

#!/bin/bash echo "Current User is :" echo $(ps | grep "$$" | awk '{print $2}') -------- oss://bucketName/objectName

FileOwner

string

No

The owner of the file. This parameter takes effect only on Linux instances. Default value: root. The value cannot exceed 64 characters in length.

Note

If you specify a different user, make sure that the user exists on the instance.

test

FileGroup

string

No

The group of the file. This parameter takes effect only on Linux instances. Default value: root. The value cannot exceed 64 characters in length.

Note

If you specify a different user group, make sure that the user group exists on the instance.

test

FileMode

string

No

The permissions on the file. This parameter takes effect only on Linux instances. You can configure this parameter in the same way as you run the chmod command.

Default value: 0644, which indicates that the owner has read and write permissions, and the group and other users have read-only permissions.

0644

Overwrite

boolean

No

Specifies whether to overwrite a file with the same name in the destination directory. Valid values:

  • true: Overwrite the file.

  • false: Do not overwrite the file.

Default value: false.

true

ClientToken

string

No

The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but make sure that the token is unique among different requests. ClientToken supports only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

123e4567-e89b-12d3-a456-426655440000

InstanceId

array

Yes

The IDs of the ECS instances to which you want to send the file. You can specify up to 50 instance IDs. Valid values of N: 1 to 50.

i-bp185dy2o3o6n****

string

No

The IDs of the ECS instances to which you want to send the file. You can specify up to 50 instance IDs. Valid values of N: 1 to 50.

i-bp185dy2o3o6n****

Tag

array<object>

No

The tags.

object

No

The tags.

Key

string

No

The key of the tag for file sending. Valid values of N: 1 to 20. The tag key cannot be an empty string.

If you use a single tag to filter resources, the resource count with this tag cannot exceed 1,000. If you use multiple tags to filter resources, the resource count with all the specified tags attached cannot exceed 1,000. If the resource count exceeds 1,000, call ListTagResources to query the resources.

The tag key can be up to 64 characters in length and cannot start with aliyun or acs:. It cannot contain http:// or https://.

TestKey

Value

string

No

The value of the tag for file sending. 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 http:// or https://.

TestValue

Response elements

Element

Type

Description

Example

object

InvokeId

string

The execution ID.

f-7d2a745b412b46****

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Success response

JSON format

{
  "InvokeId": "f-7d2a745b412b46****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

Error codes

HTTP status code

Error code

Error message

Description

400 RegionId.ApiNotSupported The api is not supported in this region. The API operation cannot be called in the specified region. Check whether the specified RegionId parameter is valid.
400 MissingParam.InstanceId The parameter instanceId is missing or empty. The instance ID is empty.
400 NumberExceed.Tags The Tags parameter number is exceed. The number of tags exceeds the maximum limit.
400 MissingParameter.TagKey You must specify Tag.N.Key. The tag key is not specified.
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. The specified Tag.N.Key parameter is invalid.
400 InvalidTagValue.Malformed The specified Tag.n.Value is not valid. The specified tag value is invalid.
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. The specified FileOwner parameter is invalid.
400 InvalidParameter.FileGroup The specified parameter FileGroup is not valid. The specified FileGroup parameter is invalid.
400 InvalidClientToken.Malformed The specified parameter clientToken is not valid. The specified ClientToken parameter does not meet the format requirements. The parameter must contain only ASCII characters and cannot exceed 64 characters in length.
500 InternalError.Dispatch An error occurred when you dispatched the request. An error occurred while the request is being sent. Try again later.
403 FileSize.ExceedLimit The length of file content exceeds limit. The length of the file content exceeds the upper limit.
403 FileName.ExceedLimit The length of file name exceeds limit. The length of the file name exceeds the upper limit.
403 FileDesc.ExceedLimit The length of file description exceeds limit. The length of the file description exceeds the upper limit.
403 InstanceIds.ExceedLimit The number of instance IDs exceeds the upper limit. The number of specified instance IDs exceeds the upper limit.
403 Operation.Forbidden The operation is not permitted. The operation is not supported.
403 InvalidTimeout.ExceedLimit The specified parameter Timeout exceeds the upper limit.
403 IdempotentParameterMismatch The specified parameter has changed while using an already used clientToken. The specified client token has already been used.
403 IdempotentProcessing The previous idempotent request(s) is still processing. A previous idempotent request is being processed. Try again later.
404 InvalidRegionId.NotFound The RegionId provided does not exist in our records. Region information error
404 InvalidInstance.NotFound The specified instances not found. The specified instance ID does not exist.
404 InvalidResourceGroup.NotFound The ResourceGroup provided does not exist in our records. The specified resource group does not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.