All Products
Search
Document Center

Elastic Compute Service:SendFile

Last Updated:Jul 09, 2024

Sends a file to one or more Elastic Compute Service (ECS) instances.

Operation description

Usage notes

  • The instances to which you want 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 to be sent 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. If the file fails to be sent, call the DescribeSendFileResults operation or see Check execution results and troubleshoot common issues for troubleshooting.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

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.

cn-hangzhou
ResourceGroupIdstringNo

The ID of the resource group. When you specify this parameter, take note of the following items:

  • The instance specified by the InstanceId parameter must belong to the specified resource group.
  • If you specify this parameter, you can call the DescribeSendFileResults operation to query file sending results in the specified resource group.
rg-bp67acfmxazb4p****
NamestringYes

The name of the file. The name can be up to 255 characters in length and can contain any characters.

file.txt
DescriptionstringNo

The description of the file. The description can be up to 512 characters in length and can contain any characters.

This is a test file.
TimeoutlongNo

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

  • A timeout error occurs when a file cannot be sent because the process slows down or because a specific module or Cloud Assistant Agent does not exist.
  • If the specified timeout period is less than 10 seconds, the system sets the timeout period to 10 seconds to ensure that the file can be sent to the instances.

Default value: 60.

60
TargetDirstringYes

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 cannot exceed 255 characters in length.

/home
ContentTypestringNo

The content type of the file. Valid values:

  • PlainText: The file content is not encoded.
  • Base64: The file content is encoded in Base64.

Default value: PlainText.

PlainText
ContentstringYes

The content of the file. The file must not exceed 32 KB in size after it is encoded in Base64.

  • If ContentType is set to PlainText, the value of Content is in plaintext.
  • If ContentType is set to Base64, the value of Content is Base64-encoded.
#!/bin/bash echo "Current User is :" echo $(ps | grep "$$" | awk '{print $2}') -------- oss://bucketName/objectName
FileOwnerstringNo

The owner of the file. This parameter takes effect only on 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.
test
FileGroupstringNo

The group of the file. This parameter takes effect only on 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 group, make sure that the user group exists in the instances.
test
FileModestringNo

The permissions on the file. This parameter takes effect only on 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.

0644
OverwritebooleanNo

Specifies whether to overwrite a file in the destination directory if the file has the same name as the sent file.

  • true
  • false

Default value: false.

true
InstanceIdarrayYes

The IDs of instances to which to send the file. You can specify up to 50 instance IDs in each request. Valid values of N: 1 to 50.

stringYes

The ID of instance N to which to send the file. You can specify up to 50 instance IDs in each request. Valid values of N: 1 to 50.

i-bp185dy2o3o6n****
Tagarray<object>No

The tags to add to the file sending task.

objectNo

The list of tags.

KeystringNo

The key of tag N of 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 the 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 contain http:// or https://. The tag key cannot start with acs: or aliyun.

TestKey
ValuestringNo

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 http:// or https://.

TestValue

Response parameters

ParameterTypeDescriptionExample
object
InvokeIdstring

The ID of the command task.

f-7d2a745b412b46****
RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
400RegionId.ApiNotSupportedThe 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.
400MissingParam.InstanceIdThe parameter instanceId is missing or empty.-
400NumberExceed.TagsThe Tags parameter number is exceed.The number of tags exceeds the maximum limit.
400MissingParameter.TagKeyYou must specify Tag.N.Key.The tag key is not specified.
400Duplicate.TagKeyThe Tag.N.Key contain duplicate key.The specified tag key already exists. Tag keys must be unique.
400InvalidTagKey.MalformedThe specified Tag.n.Key is not valid.The specified Tag.N.Key parameter is invalid.
400InvalidTagValue.MalformedThe specified Tag.n.Value is not valid.The specified tag value is invalid.
400FileTargetDir.InvalidThe target directory of file is invalid.The specified TargetDir parameter is invalid.
400FileMode.InvalidThe mode of file is invalid.The specified FileMode parameter is invalid.
400FileContent.DecodeErrorThe Content can not be base64 decoded.An error occurred when the file is decoded in Base64.
400FileContentType.InvalidThe ContentType of file is invalid.The specified ContentType parameter is invalid.
400InvalidParameter.FileOwnerThe specified parameter FileOwner is not valid.-
400InvalidParameter.FileGroupThe specified parameter FileGroup is not valid.-
403FileSize.ExceedLimitThe length of file content exceeds limit.The length of the file content exceeds the upper limit.
403FileName.ExceedLimitThe length of file name exceeds limit.The length of the file name exceeds the upper limit.
403FileDesc.ExceedLimitThe length of file description exceeds limit.The length of the file description exceeds the upper limit.
403InstanceIds.ExceedLimitThe number of instance IDs exceeds the upper limit.The number of specified instance IDs exceeds the upper limit.
403Operation.ForbiddenThe operation is not permitted.The operation is not supported.
404InvalidRegionId.NotFoundThe RegionId provided does not exist in our records.The RegionId provided does not exist
404InvalidInstance.NotFoundThe specified instances not found.The specified instance ID does not exist.
404InvalidResourceGroup.NotFoundThe ResourceGroup provided does not exist in our records.The specified resource group does not exist.
500InternalError.DispatchAn error occurred when you dispatched the request.An error occurred while the request is being sent. Try again later.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-05-12The Error code has changedView Change Details
2022-02-25The Error code has changedView Change Details