> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 全域遊戲儲存空間

> 取得使用量，以及列出、下載、上傳及刪除 XBOX 遊戲每位玩家在沙箱中讀取的全域遊戲儲存空間檔案。

全域遊戲儲存空間保存遊戲每位玩家在 XBOX 沙箱中讀取的檔案，例如新聞摘要、地圖或調整值。`xbox xbl global-storage` 會顯示沙箱使用了多少配額，並列出、下載、上傳及刪除其檔案，一次一個。讀取檔案需要可讀取遊戲 XBOX services 設定的 Partner Center 權限，而上傳或刪除檔案則需要可變更該設定的權限。

只有當遊戲沙箱已發佈的 `titlestorage.xml` 包含 `<StorageType ownerOnly="false">global</StorageType>` 時，遊戲才會讀取這些檔案；當您在 **Title Storage** 頁面上為 **Global** 選取 **Active** 時，Partner Center 會儲存此項目。若要使用 CLI 開啟此功能，請使用 [`xbl config save`](https://docs.xbox.com/zh-TW/tools/xbox-cli/commands/xbl#config-download-and-config-save) 將該元素加入沙箱的 `titlestorage.xml`，然後使用 [`xbl config publish`](https://docs.xbox.com/zh-TW/tools/xbox-cli/commands/xbl#config-publish) 發佈沙箱。

如同每個 `xbl` 命令，這些命令為實驗性功能：其選項和輸出可能會變更或移除。請參閱[實驗性命令](https://docs.xbox.com/zh-TW/tools/xbox-cli/cli-command-lifecycle.md)。

| 命令 | 效果 |
| - | - |
| `global-storage get` | 顯示沙箱的檔案使用了多少配額。 |
| `global-storage list` | 列出沙箱的檔案。 |
| `global-storage download` | 下載一個檔案。 |
| `global-storage upload` | 上傳一個最多 4 MiB 的檔案。 |
| `global-storage delete` | 刪除一個檔案。會先詢問。 |

> [!WARNING]
>
> 上傳或刪除會立即影響沙箱中的每位玩家，不需要先發佈。已刪除的檔案無法復原。

`RETAIL` 為唯讀：`upload` 和 `delete` 在其中會失敗。若要變更 `RETAIL` 的檔案，請變更開發沙箱的檔案，然後使用 [`xbl config publish`](https://docs.xbox.com/zh-TW/tools/xbox-cli/commands/xbl#cross-sandbox-publishing-replaces-global-title-storage-files) 將該沙箱發佈至 `RETAIL`，這會讓 `RETAIL` 的檔案成為其檔案的複本。

## 選項

| 選項 | 命令 | 必要 | 描述 |
| - | - | - | - |
| `--scid <guid>` 或 `--title-id <id>` | 全部 | 是，兩者擇一 | 遊戲的服務設定識別碼 (SCID)，或其 XBOX 遊戲識別碼 (CLI 會先查閱它)。請參閱[遊戲目標設定](https://docs.xbox.com/zh-TW/tools/xbox-cli/commands/xbl.md#title-targeting)。 |
| `--sandbox-id <id>` | 全部 | 是 | 遊戲執行所在的沙箱，例如 `XDKS.1` 或 `RETAIL`。`ALL`、`HIDDEN` 和 `HISTORY` 只保存設定，因此會失敗。 |
| `--seller-id <id>` | 全部 | 否 | Partner Center 賣方 ID。預設為您唯一的賣方。 |
| `--path <path>` | `get` 以外的全部 | `download`、`upload` 和 `delete` 為必要 | 檔案的路徑，例如 `news/today.json`。對於 `list`，則為資料夾 (例如 `news/`)，只列出其中的檔案。 |
| `--file-type <type>` | `download`、`upload`、`delete` | 是 | 檔案的類型：`binary`、`json` 或 `config`。 |
| `--file <file>` | `upload` | 是 | 要上傳的本機檔案，最多 4 MiB，或使用 `-` 從 stdin 讀取。 |
| `--overwrite` | `upload` | 否 | 取代 `--path` 上的檔案，無論其類型為何。未指定時，若路徑上已有檔案，`upload` 會失敗。 |
| `--dest <path>` | `download` | 否 | 儲存檔案的位置：檔案、以其名稱儲存於其中的目錄，或使用 `-` 代表 stdout。預設為目前目錄中的其名稱。現有的檔案會被取代。 |
| `--confirm`、`--yes`、`-y` | `delete` | 在互動式終端機之外 | 刪除而不詢問。 |
| `--output <format>` | 全部 | 否 | `json` (預設) 或 `json-compact`，`get` 和 `list` 另可使用 `table`。 |

未指定 `--scid` 或 `--title-id`、`--sandbox-id` 或 `--seller-id` 時，命令會使用依[內容](https://docs.xbox.com/zh-TW/tools/xbox-cli/commands/context.md)所述方式設定的值。

路徑由資料夾組成，每個資料夾由字母、數字和 `_` 組成，後接 `/`，然後是由字母、數字、`_`、`-` 和 `.` 組成的檔案名稱。一個路徑只保存一個檔案 (無論其類型為何)，因此 `download` 和 `delete` 需要 `list` 所顯示的類型。XBOX services 會在上傳 `json` 或 `config` 檔案時檢查其內容。

## 範例

查看 XDKS.1 使用了多少配額，並列出其檔案：

```bash theme={null}
xbox xbl global-storage get --title-id 1234ABCD --sandbox-id XDKS.1 --output table
xbox xbl global-storage list --title-id 1234ABCD --sandbox-id XDKS.1 --output table
```

上傳 `today.json` 作為遊戲讀取的新聞摘要：

```bash theme={null}
xbox xbl global-storage upload --title-id 1234ABCD --sandbox-id XDKS.1 --file today.json --path news/today.json --file-type json
```

以新版本取代它：

```bash theme={null}
xbox xbl global-storage upload --title-id 1234ABCD --sandbox-id XDKS.1 --file today.json --path news/today.json --file-type json --overwrite
```

將它下載到目前目錄中的 `today.json`，或將它寫入 stdout：

```bash theme={null}
xbox xbl global-storage download --title-id 1234ABCD --sandbox-id XDKS.1 --path news/today.json --file-type json
xbox xbl global-storage download --title-id 1234ABCD --sandbox-id XDKS.1 --path news/today.json --file-type json --dest -
```

刪除它：

```bash theme={null}
xbox xbl global-storage delete --title-id 1234ABCD --sandbox-id XDKS.1 --path news/today.json --file-type json
```

## 輸出

`get` 會寫入沙箱的使用量：

```json theme={null}
{
  "usedBytes": 9437696,
  "quotaBytes": 268435456
}
```

`usedBytes` 是沙箱的檔案所使用的空間，而 `quotaBytes` 是其配額：一旦檔案使用了這麼多空間，上傳就會失敗。其表格會顯示 `USED BYTES` 和 `QUOTA BYTES`。

`list` 會寫入檔案陣列，沒有任何檔案時則寫入 `[]`：

```json theme={null}
[
  {
    "path": "maps/nod_arena.bin",
    "type": "binary",
    "size": 9437184,
    "etag": "\"0x8DDF1A2B3C4D5E6\"",
    "clientFileTime": "2026-10-28T17:02:11+00:00"
  },
  {
    "path": "news/today.json",
    "type": "json",
    "size": 512,
    "etag": "\"0x8DDF1A2B3C4D5E7\""
  }
]
```

`size` 以位元組為單位，而 `clientFileTime` 是上傳檔案的時間 (若已知)。表格會顯示 `PATH`、`TYPE`、`SIZE` 和 `UPLOADED`。

`upload`、`download` 和 `delete` 是檔案作業，類似於 `cp` 和 `rm`。除了搭配 `download --dest -` 時的檔案之外，它們不會將任何內容寫入 stdout，並會在 stderr 上回報它們執行的動作：

| 命令 | 成功時的 stderr |
| - | - |
| `upload` | 傳送檔案之前為 `Uploading '<file>' to 'news/today.json'.`，然後為 `Uploaded '<file>' to 'news/today.json' (json, 512 bytes).` |
| `download` | `Downloaded 'news/today.json' to '<path>' (512 bytes).` |
| `delete` | `Deleted 'news/today.json' (json).` |

這些訊息可能會在不同版本之間變更。這三個命令不接受 `--output table`。下載失敗時，目的地已有的檔案會維持原狀。

## 結束代碼

| 結束代碼 | 意義 |
| - | - |
| `0` | 命令成功。 |
| `1` | 命令失敗。對於 `upload` 和 `delete`，未變更任何項目：要求未傳送，或服務拒絕了要求。 |
| `3` | 已傳送 `upload` 或 `delete`，但結果不明。重新執行之前，請使用 stderr 顯示的 `global-storage list` 命令檢查檔案。 |

## 錯誤

遭到拒絕的要求會以 `1` 結束，並將 JSON 錯誤寫入 stderr，如[錯誤](https://docs.xbox.com/zh-TW/tools/xbox-cli/commands/xbl.md#errors)中所述。以下是您最可能看到的錯誤：

| `code` | 原因 |
| - | - |
| `global_storage_file_not_found` | 對未保存該 `--file-type` 之檔案的路徑執行 `download` 或 `delete`；`delete` 不會刪除任何內容。`list` 會顯示每個檔案的路徑和類型。 |
| `global_storage_file_exists` | 路徑上已有檔案。傳遞 `--overwrite` 即可取代它。 |
| `global_storage_retail_read_only` | 在 `RETAIL` 中上傳或刪除。請變更開發沙箱的檔案，然後將其發佈至 `RETAIL`。 |
| `global_storage_quota_exceeded` | 沙箱的檔案已達到其配額。請刪除不需要的檔案。 |
| `xbox_access_denied` | 您沒有遊戲 XBOX services 設定或該沙箱的權限。 |
| `downstream_request_rejected` | XBOX services 拒絕了要求，例如不是有效 JSON 的 `json` 檔案。`detail` 會說明原因。 |


## Related topics

- [遊戲儲存空間概觀](https://docs.xbox.com/zh-TW/services/xbox-services/storage/title-storage/live-title-storage-overview.md)
- [XBOX services 設定](https://docs.xbox.com/zh-TW/tools/xbox-cli/commands/xbl.md)
- [連線儲存空間與遊戲儲存空間](https://docs.xbox.com/zh-TW/services/xbox-services/storage/live-connected-storage-vs-title-storage.md)
- [在 Partner Center 中設定遊戲儲存空間](https://docs.xbox.com/zh-TW/services/xbox-services/storage/title-storage/config/live-title-storage-portal-config.md)
- [全域儲存空間工具 (GlobalStorage.exe)](https://docs.xbox.com/zh-TW/tools/tools-services/live-global-storage-tool.md)
