呼叫 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**** |
| 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。 |
| 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. | 指定的標籤鍵無效。標籤鍵不能為空或 null,最多支援 128 個字元,不能以「aliyun」或「acs:」開頭,不能包含「http://」或「https://」。 |
| 400 | InvalidTagValue.Malformed | The specified Tag.n.Value is not valid. | 指定的標籤值無效。標籤值最多支援 128 個字元,並且不能包含「http://」或「https://」。 |
| 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. | 指定的參數 ClientToken 格式不符合規範要求,該參數應該只包括 ASCII 字元,且長度不應該超過 64 個字元。 |
| 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. | 指定的執行個體不存在。 |
| 404 | InvalidResourceGroup.NotFound | The ResourceGroup provided does not exist in our records. | 找不到對應的資源群組。 |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。