--- title: Tencent COS icon: /images/tencent-logo.svg description: Mount a Tencent Cloud Object Storage bucket via its S3-compatible API. --- The Tencent resource is a thin wrapper over the [S3 resource](/python/resource/s3). It maps a `TencentConfig` to an `S3Config` and reuses the exact same backend, commands, and behavior as S3, it just derives the right COS endpoint from `region`. Uses aioboto3 against Tencent COS's S3-compatible API. The endpoint is computed from `region` as `cos..myqcloud.com` (e.g. `cos.ap-guangzhou.myqcloud.com`). Pass `endpoint_url` to override. Tencent COS bucket names include the APPID suffix, e.g. `my-bucket-1250000000`. Use the full name (with the suffix) for `bucket`. ## Config ```python import os from mirage import MountMode, Workspace from mirage.resource.tencent import TencentConfig, TencentResource config = TencentConfig( bucket=os.environ["COS_BUCKET"], # e.g. my-bucket-1250000000 region=os.environ.get("COS_REGION", "ap-guangzhou"), access_key_id=os.environ["COS_SECRET_ID"], secret_access_key=os.environ["COS_SECRET_KEY"], # Optional: # endpoint_url="https://cos.ap-guangzhou.myqcloud.com", # timeout=30, # proxy="http://proxy:8080", ) resource = TencentResource(config) ws = Workspace({"/data": resource}, mode=MountMode.READ) ``` Both `READ` and `WRITE` modes are supported. ## Example ```python import asyncio import os from dotenv import load_dotenv from mirage import MountMode, Workspace from mirage.resource.tencent import TencentConfig, TencentResource load_dotenv(".env.development") config = TencentConfig( bucket=os.environ["COS_BUCKET"], region=os.environ.get("COS_REGION", "ap-guangzhou"), access_key_id=os.environ["COS_SECRET_ID"], secret_access_key=os.environ["COS_SECRET_KEY"], ) resource = TencentResource(config) async def main() -> None: ws = Workspace({"/data/": resource}, mode=MountMode.READ) r = await ws.execute("ls /data/") print(await r.stdout_str()) r = await ws.execute("find /data/ -name '*.json' | head -n 5") print(await r.stdout_str()) if __name__ == "__main__": asyncio.run(main()) ``` ## Notes - Tencent COS reports `ResourceName.S3` and routes through the same `core/s3` implementation, so the full S3 shell-command set applies. See the [S3 resource](/python/resource/s3) for the complete command reference, range reads, streaming, and the index cache fast path. - For credential setup, see [Tencent COS Setup](/home/setup/tencent).