diff --git a/TOC-tidb-cloud-filesystem.md b/TOC-tidb-cloud-filesystem.md index cdbc7e48765a9..9471cf732f222 100644 --- a/TOC-tidb-cloud-filesystem.md +++ b/TOC-tidb-cloud-filesystem.md @@ -6,7 +6,8 @@ ## GET STARTED - [Introduction](/tidb-cloud-filesystem/filesystem-intro.md) -- [Quick Start](/tidb-cloud-filesystem/filesystem-quick-start.md) +- [Quick Start via Console](/tidb-cloud-filesystem/filesystem-quick-start-console.md) +- [Quick Start via CLI](/tidb-cloud-filesystem/filesystem-quick-start.md) - Key Concepts - [Authorization](/tidb-cloud-filesystem/filesystem-authorization.md) - [Layers and Checkpoints](/tidb-cloud-filesystem/filesystem-layers-checkpoints.md) @@ -14,24 +15,27 @@ ## GUIDES - [Manage File Systems](/tidb-cloud-filesystem/manage-filesystem-resources.md) -- [Access an Existing File System](/tidb-cloud-filesystem/access-filesystem.md) -- [Work with Files and Directories](/tidb-cloud-filesystem/work-with-filesystem-data.md) - [Manage File System Tokens](/tidb-cloud-filesystem/manage-filesystem-tokens.md) -- [Share a File System](/tidb-cloud-filesystem/filesystem-sharing.md) +- [Access an Existing File System](/tidb-cloud-filesystem/access-filesystem.md) - Mount a File System - [Overview](/tidb-cloud-filesystem/filesystem-mount.md) - [Linux](/tidb-cloud-filesystem/filesystem-mount-linux.md) - [macOS](/tidb-cloud-filesystem/filesystem-mount-macos.md) - [Docker and Docker Compose](/tidb-cloud-filesystem/filesystem-mount-docker.md) +- [Work with Files and Directories](/tidb-cloud-filesystem/work-with-filesystem-data.md) +- [Share a File System](/tidb-cloud-filesystem/filesystem-sharing.md) +- [Manage Usage Limit](/tidb-cloud-filesystem/manage-filesystem-limits.md) - [Manage File System Layers and Checkpoints](/tidb-cloud-filesystem/manage-filesystem-layers.md) - [Manage Git Workspaces](/tidb-cloud-filesystem/manage-git-workspaces.md) - [Use Journals in a File System](/tidb-cloud-filesystem/use-filesystem-journals.md) - [Manage Vault Secrets for a File System](/tidb-cloud-filesystem/manage-filesystem-vault-secrets.md) - [Configure AI Providers for a File System](/tidb-cloud-filesystem/configure-filesystem-ai-providers.md) - [Automation and AI Agent Workflows](/tidb-cloud-filesystem/use-filesystem-for-automation-and-ai-agents.md) +- [Pricing & Billing](https://www.pingcap.com/tidb-cloud-filesystem-pricing-details/) ## REFERENCES - [Command Reference](/tidb-cloud-filesystem/filesystem-command-reference.md) +- [SDKs](/tidb-cloud-filesystem/filesystem-sdks.md) - [Regions and Limitations](/tidb-cloud-filesystem/filesystem-regions-and-limitations.md) - [Troubleshooting](/tidb-cloud-filesystem/filesystem-troubleshooting.md) diff --git a/tidb-cloud-filesystem/_index.md b/tidb-cloud-filesystem/_index.md index 7c7aa455f7eed..a63397dba2fc7 100644 --- a/tidb-cloud-filesystem/_index.md +++ b/tidb-cloud-filesystem/_index.md @@ -17,7 +17,9 @@ summary: TiDB Cloud Filesystem provides persistent, shared file storage for appl -[Quick Start](/tidb-cloud-filesystem/filesystem-quick-start.md) +[Quick Start via Console](/tidb-cloud-filesystem/filesystem-quick-start-console.md) + +[Quick Start via CLI](/tidb-cloud-filesystem/filesystem-quick-start.md) diff --git a/tidb-cloud-filesystem/filesystem-intro.md b/tidb-cloud-filesystem/filesystem-intro.md index e9cd6830d9ec5..c79ec04a8ff01 100644 --- a/tidb-cloud-filesystem/filesystem-intro.md +++ b/tidb-cloud-filesystem/filesystem-intro.md @@ -62,3 +62,4 @@ Choose the path that matches what you want to do: - **Create a new file system:** follow [Get Started with TiDB Cloud Filesystem](/tidb-cloud-filesystem/filesystem-quick-start.md). - **Use a file system that someone else has shared with you:** see [Access an Existing File System](/tidb-cloud-filesystem/access-filesystem.md). - **Check supported regions, platforms, and current limitations:** see [Regions and Limitations](/tidb-cloud-filesystem/filesystem-regions-and-limitations.md). +- **Integrate a client SDK into your application:** see [SDKs](/tidb-cloud-filesystem/filesystem-sdks.md). diff --git a/tidb-cloud-filesystem/filesystem-quick-start-console.md b/tidb-cloud-filesystem/filesystem-quick-start-console.md new file mode 100644 index 0000000000000..bb73af00ccf93 --- /dev/null +++ b/tidb-cloud-filesystem/filesystem-quick-start-console.md @@ -0,0 +1,77 @@ +--- +title: Get Started with TiDB Cloud Filesystem via Console +summary: Create a file system in the TiDB Cloud console, connect to it from your computer, write a test file, and view the file in the console. +--- + +# Get Started with TiDB Cloud Filesystem via Console + +Create a file system in the [TiDB Cloud console](https://tidbcloud.com/), mount it on a macOS or Linux computer, write a test file, and view its metadata in the console. + +> **Note:** +> +> TiDB Cloud Filesystem is currently in public preview. Its features and interfaces are subject to change without notice. + +## Step 1. Create a file system + +1. If you do not have a TiDB Cloud account, [sign up for one](https://tidbcloud.com/free-trial). +2. Log in to the [TiDB Cloud console](https://tidbcloud.com/) with your TiDB Cloud account. +3. In the left navigation pane, select your organization and click **File Systems**. +4. In the upper-right corner, click **Create File System**. +5. On the **Create File System** page, enter a file system name, and select a cloud provider and region. Review the usage limits in the summary. + + > **Tip:** + > + > For organizations without a credit card, the file system limits are fixed. To edit the usage limit, add a credit card to your organization. For more information, see [Manage TiDB Cloud Filesystem Usage Limit](/tidb-cloud-filesystem/manage-filesystem-limits.md). + +6. Click **Create**. When the **Your File System is Ready!** dialog appears, keep the dialog open for the next step. + +## Step 2. Mount the file system + +On macOS or Linux, follow the steps in the **Your File System is Ready!** dialog to install TiDB Cloud CLI and mount the file system. On Windows, follow [Quick Start via CLI](/tidb-cloud-filesystem/filesystem-quick-start.md) to work with files without a mount. + +1. Install the TiDB Cloud CLI `ti`. + + ```bash + curl -fsSL https://github.com/tidbcloud/ti-cli/releases/latest/download/install.sh | sh + ``` + +2. Copy and run the command under **Mount Your File System** in the same shell. The command adds `ti` to `PATH`, sets `TI_FS_TOKEN`, creates `~/tidbcloudfs`, and mounts the file system there. + + > **Note:** + > + > - The mount command includes the [default owner token](/tidb-cloud-filesystem/filesystem-authorization.md#owner-tokens) in `TI_FS_TOKEN`. This token grants full access to the file system and is displayed only once. Save it securely. Do not put the command or token in logs, issues, chat messages, or source control. + > - On Linux, mounting requires `fuse3` and access to `/dev/fuse`. If needed, follow [Install FUSE userspace tools](/tidb-cloud-filesystem/filesystem-mount-linux.md#install-fuse-userspace-tools) before running the mount command. + +3. Copy and run the command under **Start Using It** to list the mounted directory. +4. Click **Done** to open the file system overview. + +You can click **Connect** on the overview page to reopen the connection guidance, but you cannot retrieve the default owner token later. + +## Step 3. Write and view a file + +After mounting the file system, use the mounted directory to write and read a test file. + +Write a file in the mounted directory: + +```bash +echo 'Hello from TiDB Cloud Filesystem' > ~/tidbcloudfs/hello.txt +cat ~/tidbcloudfs/hello.txt +``` + +In the left navigation pane of the file system, click **Files**. The root directory lists `hello.txt`. You can search for the file or click its name to view its metadata. The console displays file information, but reading file contents and changing files require the TiDB Cloud CLI `ti` or a mount. + +## (Optional) Step 4. Unmount the file system + +If you do not need to access the file system from the mounted directory, you can unmount it: + +```bash +ti fs unmount-file-system --mount-path ~/tidbcloudfs +``` + +On Linux, FUSE can buffer writes locally until a successful unmount. If unmounting fails, follow [Finish safely](/tidb-cloud-filesystem/filesystem-mount.md#finish-safely) before leaving the machine or removing its local cache. + +## What's next + +- [Manage File Systems](/tidb-cloud-filesystem/manage-filesystem-resources.md) to inspect, rename, or delete a file system. +- [Manage File System Tokens](/tidb-cloud-filesystem/manage-filesystem-tokens.md) to create tokens with limited access. +- [Quick Start via CLI](/tidb-cloud-filesystem/filesystem-quick-start.md) for a CLI-only creation workflow. diff --git a/tidb-cloud-filesystem/filesystem-quick-start.md b/tidb-cloud-filesystem/filesystem-quick-start.md index 974dca522f6db..e5b8bd1e561cf 100644 --- a/tidb-cloud-filesystem/filesystem-quick-start.md +++ b/tidb-cloud-filesystem/filesystem-quick-start.md @@ -1,9 +1,9 @@ --- -title: Get Started with TiDB Cloud Filesystem +title: Get Started with TiDB Cloud Filesystem via CLI summary: Learn how to create a persistent TiDB Cloud file system, read and write files, and optionally access them through a local mount. --- -# Get Started with TiDB Cloud Filesystem +# Get Started with TiDB Cloud Filesystem via CLI [TiDB Cloud Filesystem](/tidb-cloud-filesystem/filesystem-intro.md) is a persistent, shared cloud file system for applications, automation, and AI agents. Files remain available independently of the machine or process that creates them, so you can reuse a workspace across sessions and environments. diff --git a/tidb-cloud-filesystem/filesystem-sdks.md b/tidb-cloud-filesystem/filesystem-sdks.md new file mode 100644 index 0000000000000..0177b2a8007d7 --- /dev/null +++ b/tidb-cloud-filesystem/filesystem-sdks.md @@ -0,0 +1,49 @@ +--- +title: SDKs +summary: Learn how TiDB Cloud Filesystem relates to the Drive9 workspace engine and find client SDK documentation for six programming languages. +--- + +# SDKs + +TiDB Cloud Filesystem uses the Drive9 workspace engine to run file system operations. TiDB Cloud Filesystem is PingCAP's official hosted Drive9 service on TiDB Cloud. Drive9 is an open-source, community-based project owned by PingCAP, and TiDB Cloud Filesystem is its managed cloud service. At the API and SDK layers, you directly invoke the drive9 endpoints exposed by TiDB Cloud Filesystem service. + +Drive9 is an open-source project (Apache 2.0) maintained in the [mem9-ai/drive9 repository](https://github.com/mem9-ai/drive9). Besides the workspace engine, that repository publishes client SDKs for several programming languages. The SDKs and their documentation are maintained there, so the guides listed on this page are the source of truth for SDK installation, configuration, and API details. + +The SDK guides describe how a client connects to a Drive9 server, including how to provide the server URL and an API key. + +The API Keys mentioned in Drive9 SDK/API documentations. + +|TiDB Cloud Filesystem Object|Drive9 SDK/API Usage| +|:--|:--| +|TiDB Cloud API Key|File system control plane actions| +|File System Token|File system data plane actions| + +Available server URL for Drive9 SDK/API server URL to TiDB Cloud Filesystem regions. + +| TiDB Cloud Filesystem Region| Server URL for Drive9 SDK/API | API Key| +|:--|:--|:--| +|`aws-us-east-1`|`https://aws-us-east-1.drive9.ai`| FS token| +|`aws-us-west-2`|`https://aws-us-west-2.drive9.ai`| FS token| +|`aws-ap-southeast-1`|`https://aws-ap-southeast-1.drive9.ai`| FS token| +|`gcp-us-east1`|`https://gcp-us-east-1.drive9.ai`| FS token| +|`azure-centralus`|`https://azure-centralus.drive9.ai`|FS token| +|`alicloud-ap-southeast-1`|`https://alicloud-ap-southeast-1.drive9.ai`|FS token| + +## Available SDKs + +| Language | Repository location | Documentation | +| --- | --- | --- | +| TypeScript | `clients/drive9-js` | [TypeScript SDK integration guide](https://github.com/mem9-ai/drive9/blob/main/docs/guides/typescript-sdk-integration.md) | +| Go | `pkg/client` | [Go SDK integration guide](https://github.com/mem9-ai/drive9/blob/main/docs/guides/go-sdk-integration.md) | +| Python | `clients/drive9-py` | [drive9-py README](https://github.com/mem9-ai/drive9/blob/main/clients/drive9-py/README.md) | +| Rust | `clients/drive9-rs` | [drive9-rs README](https://github.com/mem9-ai/drive9/blob/main/clients/drive9-rs/README.md) | +| Kotlin | `clients/drive9-kotlin` | [drive9-kotlin README](https://github.com/mem9-ai/drive9/blob/main/clients/drive9-kotlin/README.md) | +| Swift | `clients/drive9-swift` | [drive9-swift README](https://github.com/mem9-ai/drive9/blob/main/clients/drive9-swift/README.md) | + +The SDKs are developed and released with the Drive9 project, so they can move ahead of the TiDB Cloud Filesystem service. Before you adopt an SDK for a TiDB Cloud Filesystem workload, check its documentation for the current server endpoint, credentials, and supported operations. + +## What's next + +- [TiDB Cloud CLI (`ti`)](/ai/ti/ti-quick-start.md) to install, configure, and update the CLI. +- [Work with Files and Directories](/tidb-cloud-filesystem/work-with-filesystem-data.md) to manage file system data from the command line. +- [Automation and AI Agent Workflows](/tidb-cloud-filesystem/use-filesystem-for-automation-and-ai-agents.md) to use a file system in automated workflows. diff --git a/tidb-cloud-filesystem/manage-filesystem-limits.md b/tidb-cloud-filesystem/manage-filesystem-limits.md new file mode 100644 index 0000000000000..7035de048f105 --- /dev/null +++ b/tidb-cloud-filesystem/manage-filesystem-limits.md @@ -0,0 +1,39 @@ +--- +title: Manage TiDB Cloud Filesystem Usage Limit +summary: Learn how to view file system usage and free limits in the TiDB Cloud console, and edit usage limits after adding a credit card. +--- + +# Manage TiDB Cloud Filesystem Usage Limit + +> **Note:** +> +> The limits in [Limits without a credit card on the organization](#limits-without-a-credit-card-on-the-organization) apply only when your TiDB Cloud organization has no credit card. + +You can create and use file systems in the TiDB Cloud Filesystem service without a credit card, but each free file system has tighter capacity limits. You can raise these limits after adding a credit card to your organization. + +## Limits without a credit card on the organization + +When your organization has **no credit card registered**, the following limits apply to each free file system: + +- One file system per region +- 2,000 files per file system +- 2 GB of storage per file system +- 500 MB maximum size for a single file + +With a credit card, you can set higher limits and continue with pay-as-you-go usage. See [TiDB Cloud Filesystem pricing](https://www.pingcap.com/tidb-cloud-filesystem-pricing-details/) for billing details. + +## View file system usage + +To view the current usage of a file system, go to its overview page in the [TiDB Cloud console](https://tidbcloud.com/) and check the **Usage** area. For usage details, click **Usage** in the left navigation pane. + +## When a file system reaches a limit + +When a file system reaches a limit, existing files remain readable, but the file system stops accepting new writes. The TiDB Cloud console shows a warning. + +## Update the usage limit + +1. In the TiDB Cloud console, navigate to the [**File Systems**](https://tidbcloud.com/filesystems) page, select the **Cloud Provider** and **Region** for the file system, and click the name of your target file system. +2. On the overview page of the file system, click **Edit Usage Limit** in the **Usage** area. +3. Set maximum storage, file count, and file size as needed, then click **Save**. + + If your organization has no credit card, these fields are disabled. Add a credit card to edit them and enable pay-as-you-go usage. diff --git a/tidb-cloud-filesystem/manage-filesystem-resources.md b/tidb-cloud-filesystem/manage-filesystem-resources.md index 0e1af6d9bbedf..66345de400ccc 100644 --- a/tidb-cloud-filesystem/manage-filesystem-resources.md +++ b/tidb-cloud-filesystem/manage-filesystem-resources.md @@ -1,21 +1,39 @@ --- title: Manage File Systems in TiDB Cloud Filesystem -summary: Learn how to create, inspect, check, select, and delete file systems in TiDB Cloud Filesystem by using TiDB Cloud CLI. +summary: Learn how to create, inspect, and delete file systems by using the TiDB Cloud console or CLI, rename them in the console, and check access with CLI. aliases: ['/ai/manage-filesystem-resources'] --- # Manage File Systems in TiDB Cloud Filesystem -You can use [TiDB Cloud CLI (`ti`)](/ai/ti/ti-overview.md) to create, inspect, check, select, and delete file systems in TiDB Cloud Filesystem. +You can use the [TiDB Cloud console](https://tidbcloud.com/) or [TiDB Cloud CLI (`ti`)](/ai/ti/ti-overview.md) to create, inspect, and delete file systems in TiDB Cloud Filesystem. The console also lets you rename a file system; the CLI provides access diagnostics. For command syntax, flags, and output fields, see the [`ti fs` command reference](/ai/ti/reference/ti-filesystem.md). ## Prerequisites -Before you begin, follow [Get Started with TiDB Cloud Filesystem](/tidb-cloud-filesystem/filesystem-quick-start.md) to install TiDB Cloud CLI (`ti`) and configure the access. +- To use the [TiDB Cloud console](https://tidbcloud.com/) to manage file systems, log in to the console and select your organization. +- To use the TiDB Cloud CLI (`ti`) to manage file systems, follow [Quick Start via CLI](/tidb-cloud-filesystem/filesystem-quick-start.md) to install `ti` and configure access. ## Create a file system + + +
+ +1. In the left navigation pane of the [TiDB Cloud console](https://tidbcloud.com), select your organization and click **File Systems**. +2. In the upper-right corner, click **Create File System**. +3. On the **Create File System** page, enter a file system name, and select a **Cloud Provider** and **Region**. +4. (Optional) Review and edit the usage limits in the summary. + + To edit the usage limits, add a credit card to your organization. Without a credit card, the free limits cannot be edited during creation. For more information, see [Manage Usage Limit](/tidb-cloud-filesystem/manage-filesystem-limits.md). + +5. Click **Create**. The **Your File System is Ready!** dialog offers optional steps to install TiDB Cloud CLI and mount the file system on macOS or Linux. The default owner token in the mount command is shown only once; save it securely before closing the dialog. + +
+ +
+ Create a file system and wait until it is ready: ```shell @@ -43,8 +61,27 @@ Setting `TI_FS_FILE_SYSTEM_ID` lets subsequent commands identify the target file > > Do not put credentials, connection strings, private paths, or personal data in file system labels. +
+ +
+ ## List and inspect file systems + + +
+ +1. In the left navigation pane of the [TiDB Cloud console](https://tidbcloud.com), select your organization and click **File Systems**. +2. On the [**File Systems**](https://tidbcloud.com/filesystems) page, select a cloud provider and region to list file systems in that location. Use **Search Name** or **Status** to narrow the list. + +To view details of a file system, click the file system's name to go to its overview page. + +To change its display name, click **...** in the upper-right corner of the overview page and select **Rename**. + +
+ +
+ List the file systems available in the current region: ```shell @@ -66,6 +103,10 @@ The CLI does not automatically select a file system based on the number of file The current CLI does not provide a command to change a file system's display name or labels after creation. Choose these values when you create the file system. +
+ +
+ ## Check access Check whether the CLI can access a file system: @@ -87,6 +128,20 @@ For common access and connectivity issues, see [Troubleshoot TiDB Cloud Filesyst > > Deleting a file system permanently removes its remote data. Before deletion, stop applications that are using the file system and successfully unmount any active local mounts. For information about finishing pending writes safely, see [Finish safely](/tidb-cloud-filesystem/filesystem-mount.md#finish-safely). + + +
+ +1. In the TiDB Cloud console, open your organization's [**File Systems**](https://tidbcloud.com/filesystems) page, then select the **Cloud Provider** and **Region** for the target file system. +2. In the row of the target file system, click **...**, and then select **Delete**. +3. In the confirmation dialog, enter the requested region and file system name in the form `region/name`, then click **I understand, delete it.** + +Deletion is asynchronous. After the request is submitted, the file system might remain visible with the status `deleting` until deletion finishes. + +
+ +
+ Delete a file system by its ID: ```shell @@ -95,6 +150,10 @@ ti fs delete-file-system --file-system-id "" File system deletion is asynchronous. After the service accepts the request, the CLI reports the file system status as `deleting` and removes the matching locally stored credential. This status means that deletion has started, not that the remote file system and its data have already been removed. +
+ +
+ ## What's next - [Manage File System Tokens](/tidb-cloud-filesystem/manage-filesystem-tokens.md) to generate, delegate, rotate, or revoke file system access. diff --git a/tidb-cloud-filesystem/manage-filesystem-tokens.md b/tidb-cloud-filesystem/manage-filesystem-tokens.md index fa912a70f5aa8..539e11f120a49 100644 --- a/tidb-cloud-filesystem/manage-filesystem-tokens.md +++ b/tidb-cloud-filesystem/manage-filesystem-tokens.md @@ -8,34 +8,47 @@ aliases: ['/ai/manage-filesystem-tokens'] In TiDB Cloud Filesystem, you can use file system tokens to give users, applications, and automation access to a file system without sharing your TiDB Cloud API credentials. -An [owner token](/tidb-cloud-filesystem/filesystem-authorization.md#owner-tokens) grants full access to a file system. A [scoped token](/tidb-cloud-filesystem/filesystem-authorization.md#scoped-tokens) limits access to specific paths and operations. For details, see [Authorization](/tidb-cloud-filesystem/filesystem-authorization.md). +- An [owner token](/tidb-cloud-filesystem/filesystem-authorization.md#owner-tokens) grants full access to a file system. +- A [scoped token](/tidb-cloud-filesystem/filesystem-authorization.md#scoped-tokens) limits access to specific paths and operations. ## Prerequisites Before you begin: -- [Install TiDB Cloud CLI](/tidb-cloud-filesystem/filesystem-quick-start.md#step-1-install-tidb-cloud-cli). -- Have access to an existing file system in TiDB Cloud Filesystem. If you do not have one, follow [Get Started with TiDB Cloud Filesystem](/tidb-cloud-filesystem/filesystem-quick-start.md) to create one. +- Have access to an existing file system in TiDB Cloud Filesystem. If you do not have one, follow [Quick Start via Console](/tidb-cloud-filesystem/filesystem-quick-start-console.md) or [Quick Start via CLI](/tidb-cloud-filesystem/filesystem-quick-start.md) to create one. +- For CLI operations, [install TiDB Cloud CLI](/tidb-cloud-filesystem/filesystem-quick-start.md#step-1-install-tidb-cloud-cli). -Listing, enabling, disabling, and deleting tokens require either an owner token supplied through `TI_FS_TOKEN` or `--fs-token`, or TiDB Cloud API credentials with an explicit `--file-system-id`. These operations do not use a locally stored token automatically. Scoped-token generation can use a locally stored owner token. Each section below explains any additional requirements. +To list, enable, disable, or delete tokens with the CLI, provide an owner token through `TI_FS_TOKEN` or `--fs-token`, or use TiDB Cloud API credentials with an explicit `--file-system-id`. These operations do not automatically use a locally stored token. Scoped-token generation can use a locally stored owner token. Each section below explains any additional requirements. > **Note:** > -> Store file system tokens securely. Commands that create or refresh a token return its value only once; you cannot retrieve it later. +> Store file system tokens securely. When you create or refresh a token, its plaintext is returned only once and cannot be retrieved later. ## Import an existing token -If you already have a file system token, import it to the local CLI credential store: +If you already have a file system token, including the default owner token shown when you create a file system in the TiDB Cloud console, save its plaintext to a secure file and import it to the local CLI credential store: ```shell -ti fs import-file-system-token --from-file ./fs-token --region aws-us-east-1 +ti fs import-file-system-token --from-file ./fs-token --region "" ``` -The CLI validates the token, extracts the file system ID from it, verifies connectivity, and stores the token locally. +The CLI validates the token, extracts the file system ID from it, verifies connectivity, and stores the token locally. If the token is still available through `TI_FS_TOKEN`, you can use it for CLI commands without importing it. ## Generate an owner token -Creating a file system returns an owner token. That token does not expire, and the CLI stores it locally and uses it for later commands. Before you revoke it, generate and validate a replacement as described in [Rotate or revoke a token](#rotate-or-revoke-a-token). Tokens you generate later with `--ttl` expire on their own. + + +
+ +The TiDB Cloud console creates a default owner token when you create a file system. Its plaintext appears only in the **Your File System is Ready!** dialog. + +For an additional owner token, use the **CLI** tab. + +
+ +
+ +When you create a file system with the CLI, it returns a non-expiring owner token, stores it locally, and uses it for later commands. Generate an additional owner token when another trusted environment needs full access. @@ -57,8 +70,37 @@ ti fs generate-file-system-token \ The CLI does not store the generated token locally by default. To store it locally, add `--store-locally` to the preceding command. If a different token is already stored for this file system, also add `--replace`. +
+ +
+ ## Generate and delegate a scoped token + + +
+ +If you want to restrict a token to a specific directory, create that directory before generating the token. + +1. In the TiDB Cloud console, navigate to the [**File Systems**](https://tidbcloud.com/filesystems) page, select the cloud provider and region, and then click the name of your target file system. +2. On the overview page of the file system, click **Access Tokens** in the left navigation pane. +3. In the upper-right corner, click **Create Token**. +4. Configure the token by providing the following information: + + - **Token name**: enter a name for the token. + - **Access path (optional)**: specify an access path to limit the token's access to a specific directory. If you leave the path empty, the token applies to `/`. + - **Expiration**: choose when the token expires. The default is one hour. + - **Permission**: select only the operations the token needs. For details, see [Authorization](/tidb-cloud-filesystem/filesystem-authorization.md#scoped-tokens). + +5. Click **Create**. +6. In the displayed dialog, copy the token and store it securely before clicking **Done**. Its plaintext is shown only once. + +Provide the token and file system region to the receiving environment. When mounting with a token restricted to a directory, set the CLI `--remote-path` option to that directory. + +
+ +
+ On a trusted machine, use an owner token to generate a scoped token. Supply the owner token through `--fs-token` or `TI_FS_TOKEN`, or use the owner token stored locally for the selected file system. Before using this example, create the remote `/workspace` directory if it does not exist. Use the locally stored owner token to grant an agent permission to read, list, and write files in that directory: @@ -87,8 +129,29 @@ To mount the directory with this token, specify `--remote-path /workspace`. A to For more information about scoped permissions and credential selection, see [Authorization](/tidb-cloud-filesystem/filesystem-authorization.md). +
+ +
+ ## Inspect and change token status +> **Warning:** +> +> Before deactivating, rotating, or deleting a token used by an active mount, stop applications that are writing to the mount and successfully unmount it. The CLI can detect known local mounts but cannot discover mounts on other machines. Coordinate with those machines before changing the token. For more information, see [Finish safely](/tidb-cloud-filesystem/filesystem-mount.md#finish-safely). + + + +
+ +1. In the TiDB Cloud console, navigate to the [**File Systems**](https://tidbcloud.com/filesystems) page, select the cloud provider and region, and then click the name of your target file system. +2. On the overview page of the file system, click **Access Tokens** in the left navigation pane. +3. On the **Access Tokens** page, you can view each token's ID, status, access path, permissions, expiration, and creation time. +4. To suspend a token, click **...** in the row of the target token, and then select **Deactivate**. To restore a deactivated token, click **...**, and then select **Activate**. + +
+ +
+ For an owner-token-only environment, set `TI_FS_TOKEN` to the owner token and `TI_REGION_CODE` to the file system's region before running the commands below. Keep management credentials separate from the scoped token you give to the recipient. A scoped token cannot manage other tokens. List non-secret metadata for file system tokens: @@ -101,12 +164,30 @@ ti fs list-file-system-tokens \ The output does not include token plaintext. If you lose an owner token, generate a replacement using TiDB Cloud API credentials. You cannot recover the original token by listing tokens. -Use [`disable-file-system-token`](/ai/ti/reference/ti-fs-disable-file-system-token.md) to temporarily suspend a token, and [`enable-file-system-token`](/ai/ti/reference/ti-fs-enable-file-system-token.md) to restore it. +Use [`disable-file-system-token`](/ai/ti/reference/ti-fs-disable-file-system-token.md) to temporarily suspend a token, and [`enable-file-system-token`](/ai/ti/reference/ti-fs-enable-file-system-token.md) to restore it. These correspond to **Deactivate** and **Activate** in the console. With owner token authentication, these two commands can change only scoped tokens. To enable or disable an owner token, use TiDB Cloud API credentials, specify `--file-system-id`, and unset `TI_FS_TOKEN` so it does not override the API credentials. Do not supply `--fs-token` for that request. Allow approximately 10 seconds for the change to take effect before verifying access. +
+ +
+ ## Rotate or revoke a token +To rotate or revoke a token, it is recommended to use the CLI commands. The TiDB Cloud console does not offer the `refresh-file-system-token` operation of the CLI. + + + +
+ +To replace a scoped token in the TiDB Cloud console, [create a new token](#generate-and-delegate-a-scoped-token) with the required path, permissions, and expiration. Distribute and validate the new token before retiring the old one. Then, go to the **Access Tokens** page of the target file system, locate the row of the old token, click **...**, and then select **Delete**. + +To replace an owner token, [generate another owner token with the CLI](#generate-an-owner-token) before deleting the old one in the TiDB Cloud console. + +
+ +
+ Use [`refresh-file-system-token`](/ai/ti/reference/ti-fs-refresh-file-system-token.md) to rotate a file system token. When you refresh a locally stored token, the CLI automatically updates the local credential. When you refresh a token provided through `--fs-token` or `TI_FS_TOKEN`, the CLI returns the new token in the command output without storing it locally. @@ -115,10 +196,6 @@ When you refresh a locally stored token, the CLI automatically updates the local > > If a refresh request times out, the service might have rotated the token without returning the new value to you. Do not retry with the old token. Generate a new owner token using TiDB Cloud API credentials. -> **Warning:** -> -> Before rotating, disabling, or deleting a token used by an active mount, stop applications that are writing to the mount and successfully unmount it. The CLI can detect known local mounts but cannot discover mounts on other machines. Coordinate with those machines before changing the token. For more information, see [Finish safely](/tidb-cloud-filesystem/filesystem-mount.md#finish-safely). - Before retiring a token, distribute and validate its replacement. Then revoke the old token by its token ID: ```shell @@ -131,6 +208,10 @@ If the deleted token matches the locally stored token, the CLI automatically rem Disabling or revoking an owner token does not automatically revoke scoped tokens generated from it. Review and revoke those scoped tokens separately when necessary. +
+ +
+ ## What's next - [Share a File System](/tidb-cloud-filesystem/filesystem-sharing.md) diff --git a/tidb-cloud-filesystem/work-with-filesystem-data.md b/tidb-cloud-filesystem/work-with-filesystem-data.md index 3b7fc9f9ee808..ccd86b8fef4e4 100644 --- a/tidb-cloud-filesystem/work-with-filesystem-data.md +++ b/tidb-cloud-filesystem/work-with-filesystem-data.md @@ -1,23 +1,63 @@ --- title: Work with Files and Directories in TiDB Cloud Filesystem -summary: Learn how to upload, download, read, organize, and search files in TiDB Cloud Filesystem using CLI commands without a local mount. +summary: Learn how to view file metadata in the console and upload, download, read, organize, and search files with TiDB Cloud CLI. aliases: ['/ai/work-with-filesystem-data'] --- # Work with Files and Directories in TiDB Cloud Filesystem -In TiDB Cloud Filesystem, you can use TiDB Cloud CLI (`ti`) to upload, download, read, organize, and search files without mounting the file system. For all commands and options, see the [`ti fs` reference](/ai/ti/reference/ti-filesystem.md). +In TiDB Cloud Filesystem, you can browse file and directory metadata in the TiDB Cloud console or use TiDB Cloud CLI (`ti`) to upload, download, read, organize, and search files without mounting the file system. For all commands and options, see the [`ti fs` reference](/ai/ti/reference/ti-filesystem.md). -If your tools need local file paths, [mount the file system](/tidb-cloud-filesystem/filesystem-mount.md). +If you [mount the file system](/tidb-cloud-filesystem/filesystem-mount.md) to your machine, you can work with files and directories as you do with a local file system. ## Prerequisites -Before you begin: +The following prerequisites apply to CLI operations. If you only need to browse file metadata in the TiDB Cloud console, see [View files](#view-files-via-the-console). - [Install TiDB Cloud CLI](/tidb-cloud-filesystem/filesystem-quick-start.md#step-1-install-tidb-cloud-cli). - [Create a file system](/tidb-cloud-filesystem/manage-filesystem-resources.md) or obtain access to an existing one. - Select the file system and make its token available to `ti`. For available access options, see [Access an Existing File System](/tidb-cloud-filesystem/access-filesystem.md). +## View files + + + +
+ +1. In the [TiDB Cloud console](https://tidbcloud.com/), navigate to the [**File Systems**](https://tidbcloud.com/filesystems) page for your organization, select the cloud provider and region, and then click the name of your target file system. +2. In the left navigation pane, click **Files**. The page lists directories and files with their type, size, and modification time. +3. Expand a directory to browse its contents, use **Search** to filter the visible file tree, or click a file name to view its metadata. + +The console displays file metadata. To read file contents or change files and directories, use the CLI commands or [mount the file system](/tidb-cloud-filesystem/filesystem-mount.md). + +
+ +
+ +List the contents of a directory: + +```shell +ti fs list-files --path /reports --output text +``` + +Example output: + +```text +NAME TYPE SIZE MTIME +archive dir 0 0 +report.md file 23 0 +``` + +Inspect metadata for a file or directory: + +```shell +ti fs describe-file --path /reports/report.md +``` + +
+ +
+ ## Upload and download files Upload a local file to the file system: @@ -41,7 +81,7 @@ You can also use `copy-file` to copy files or directories within the file system To copy a directory recursively, use `--recursive`. For all supported copy operations and options, see the [`copy-file` reference](/ai/ti/reference/ti-fs-copy-file.md). -## Read and inspect files and directories +## Read files Read the complete contents of a file: @@ -60,26 +100,6 @@ ti fs read-file \ --length 1024 ``` -List the contents of a directory: - -```shell -ti fs list-files --path /reports --output text -``` - -Example output: - -```text -NAME TYPE SIZE MTIME -archive dir 0 0 -report.md file 23 0 -``` - -Inspect metadata for a file or directory: - -```shell -ti fs describe-file --path /reports/report.md -``` - ## Organize files and directories Create a directory: