应用
提交应用
向你的应用发送一次更改。速率限制为每个用户每 2 秒 1 次请求,外加每个应用每 5 秒 1 次请求。
POST
/
v2
/
apps
/
{app_id}
/
commit
提交应用
curl --request POST \
--url https://api.squarecloud.app/v2/apps/{app_id}/commit \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.squarecloud.app/v2/apps/{app_id}/commit"
payload = {}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api.squarecloud.app/v2/apps/{app_id}/commit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/commit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.squarecloud.app/v2/apps/{app_id}/commit"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.squarecloud.app/v2/apps/{app_id}/commit")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/apps/{app_id}/commit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"status": "success"
}
提交(commit)会将单个文件或一个
.zip 压缩包直接流式写入已存在的应用,而无需重新创建它。.zip 会在目标目录中被解压,其他任何文件则按原样写入。这使它成为从 CI 流水线或部署脚本推送小型代码更改、热修复或配置更新的最快方式。
提交本身不会重启应用:发送更改后,需要调用重启应用才能让新文件生效。若是新应用的首次部署,请改用上传应用;若只想原地编辑单个文件而无需重新上传,请参阅文件管理器端点。
上传大小限制为每个文件 100 MB。包含路径穿越(..)、路径分隔符或控制字符的文件名会在任何更改被应用之前被拒绝。在工作区共享的应用上,调用者需要具备 Maintainer 或 Administrator 角色。
参数
string
必填
应用的 ID。你可以在应用控制台的 URL 中找到它。
file
必填
使用 FormData 或 NodeJS Buffer(单个文件或压缩包 [zip])
string
可选。应用内部的目标目录。
.zip 会在此处解压;任何其他文件会被放置在 path/filename。默认为应用根目录。响应
string
指示调用是否成功。成功时为
success,否则为 error。{
"status": "success"
}
常见错误
| 代码 | HTTP | 说明 |
|---|---|---|
INVALID_CONTENT_TYPE | 415 | 请求体不是 multipart/form-data。 |
INVALID_FILE | 400 | 表单数据中未找到文件字段。 |
INVALID_FILENAME | 400 | 文件名包含路径分隔符、.. 或控制字符。 |
INVALID_PATH | 400 | path 查询参数包含路径穿越或 shell 元字符。 |
FILE_TOO_LARGE | 413 | 上传超过了每个文件 100 MB 的限制。 |
⌘I
提交应用
curl --request POST \
--url https://api.squarecloud.app/v2/apps/{app_id}/commit \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api.squarecloud.app/v2/apps/{app_id}/commit"
payload = {}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api.squarecloud.app/v2/apps/{app_id}/commit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.squarecloud.app/v2/apps/{app_id}/commit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.squarecloud.app/v2/apps/{app_id}/commit"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.squarecloud.app/v2/apps/{app_id}/commit")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.squarecloud.app/v2/apps/{app_id}/commit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"status": "success"
}

