Manage Tencent Cloud COS buckets and objects: list, upload, download, delete, batch-delete by prefix, generate pre-signed URLs, calculate storage usage (du), and copy objects.
How this skill is triggered — by the user, by Claude, or both
Slash command
/acedatacloud-ai-media:tencentcloud-cosThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Manage Tencent Cloud COS buckets and objects via the official `cos-python-sdk-v5` client.
Manage Tencent Cloud COS buckets and objects via the official cos-python-sdk-v5 client.
Setup: See tencentcloud authentication for SecretId / SecretKey / region setup. The SDK reads
TENCENTCLOUD_SECRET_ID/TENCENTCLOUD_SECRET_KEY/TENCENTCLOUD_REGIONfrom the environment.
The skill ships scripts/cos.py — a self-contained CLI that wraps every COS operation below. Prefer this over hand-rolled SDK calls when the user's request maps cleanly onto one of its subcommands; it's what the maintained code paths exercise.
COS=$SKILL_DIR/scripts/cos.py
python3 $COS buckets # list all buckets
python3 $COS ls mydata-1250000000 --prefix images/ # list objects
python3 $COS upload mydata-1250000000 ./report.pdf --key docs/report-2026.pdf
python3 $COS download mydata-1250000000 docs/report-2026.pdf --output ./out.pdf
python3 $COS url mydata-1250000000 docs/report-2026.pdf --expires 3600
python3 $COS du mydata-1250000000 --prefix logs/
python3 $COS cp mydata-1250000000 old/path.txt new/path.txt
python3 $COS batch-delete mydata-1250000000 --prefix temp/old/ --dry-run
python3 $COS batch-delete mydata-1250000000 --prefix temp/old/ # actually delete
python3 $COS info mydata-1250000000 docs/report-2026.pdf
Run python3 $COS --help (or python3 $COS <cmd> --help) for full flags. Pass --region <region> to override per-call.
pip install cos-python-sdk-v5
Tencent Cloud bucket names always end in -<APPID>, e.g. mydata-1250000000. The APPID is the numeric account identifier. The SDK requires the full name-APPID form everywhere a bucket is named.
import os
from qcloud_cos import CosConfig, CosS3Client
config = CosConfig(
Region=os.environ["TENCENTCLOUD_REGION"],
SecretId=os.environ["TENCENTCLOUD_SECRET_ID"],
SecretKey=os.environ["TENCENTCLOUD_SECRET_KEY"],
Scheme="https",
)
client = CosS3Client(config)
resp = client.list_buckets()
for b in resp["Buckets"]["Bucket"]:
print(b["Name"], b["Location"], b["CreationDate"])
# Single page (max 1000 objects)
resp = client.list_objects(Bucket="mydata-1250000000", Prefix="images/", Delimiter="/")
for obj in resp.get("Contents", []):
print(obj["Key"], int(obj["Size"]), obj["LastModified"])
# Paginate through everything
marker = ""
while True:
resp = client.list_objects(Bucket="mydata-1250000000", Prefix="logs/", Marker=marker, MaxKeys=1000)
for obj in resp.get("Contents", []):
print(obj["Key"])
if resp.get("IsTruncated") != "true":
break
marker = resp["NextMarker"]
# Streaming upload — handles multipart / resumes / 5GB+ files transparently
client.upload_file(
Bucket="mydata-1250000000",
Key="uploads/2026/report.pdf",
LocalFilePath="./report.pdf",
)
client.download_file(
Bucket="mydata-1250000000",
Key="uploads/2026/report.pdf",
DestFilePath="./report.pdf",
)
# Default expiry 1 hour; pass Expired=86400 for 24h, etc.
url = client.get_presigned_url(
Method="GET",
Bucket="mydata-1250000000",
Key="uploads/2026/report.pdf",
Expired=3600,
)
print(url)
client.delete_object(Bucket="mydata-1250000000", Key="uploads/old-file.txt")
# 1) Always preview first
to_delete = []
marker = ""
while True:
resp = client.list_objects(Bucket="mydata-1250000000", Prefix="temp/old/", Marker=marker, MaxKeys=1000)
for obj in resp.get("Contents", []):
to_delete.append({"Key": obj["Key"]})
if resp.get("IsTruncated") != "true":
break
marker = resp["NextMarker"]
print(f"Would delete {len(to_delete)} objects")
for o in to_delete[:10]:
print(" -", o["Key"])
# 2) Confirm with the user before running this:
# resp = client.delete_objects(Bucket="mydata-1250000000", Delete={"Object": to_delete, "Quiet": "false"})
# print("Deleted:", len(resp.get("Deleted", [])))
total_bytes = 0
total_count = 0
marker = ""
while True:
resp = client.list_objects(Bucket="mydata-1250000000", Prefix="logs/", Marker=marker, MaxKeys=1000)
for obj in resp.get("Contents", []):
total_bytes += int(obj["Size"])
total_count += 1
if resp.get("IsTruncated") != "true":
break
marker = resp["NextMarker"]
print(f"{total_count} objects, {total_bytes / 1024 / 1024:.1f} MiB")
client.copy_object(
Bucket="mydata-1250000000",
Key="new/path.txt",
CopySource={
"Bucket": "mydata-1250000000",
"Key": "old/path.txt",
"Region": os.environ["TENCENTCLOUD_REGION"],
},
)
delete_objects call is irreversible — there's no recycle bin in COS by default.CopySource. Mismatched region triggers NoSuchBucket.download_file overwrites the destination without asking. Pick DestFilePath carefully when scripting in a loop.| Symptom | Likely cause |
|---|---|
NoSuchBucket | Wrong region, wrong APPID suffix on the bucket name |
AccessDenied | Sub-account missing QcloudCOSReadOnlyAccess / QcloudCOSDataReadOnly etc. |
SignatureDoesNotMatch | SecretKey was pasted with leading / trailing whitespace, or the system clock is off by more than 5 minutes |
RequestTimeTooSkewed | Same — clock skew |
npx claudepluginhub acedatacloud/skills --plugin acedatacloud-ai-toolsCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.