Upload files to Tencent Cloud COS (腾讯云对象存储) with automatic URL generation.
Set these environment variables:
export TENCENT_SECRET_ID=your-secret-id
export TENCENT_SECRET_KEY=your-secret-key
export TENCENT_COS_BUCKET=your-bucket-name
export TENCENT_COS_REGION=ap-guangzhou
export TENCENT_COS_PATH=uploads/ # optional
Then upload:
node cos-upload.js /path/to/file.png
node cos-upload.js /path/to/file.png \
--secret-id AKIDxxx \
--secret-key xxx \
--bucket my-bucket-1250000000 \
--region ap-guangzhou \
--path images/
On successful upload, returns:
https://{bucket}.cos.{region}.myqcloud.com/{key}| Variable | Required | Description |
|---|---|---|
| ---------- | ---------- | ------------- |
TENCENT_SECRET_ID | Yes | Tencent Cloud API Secret ID |
TENCENT_SECRET_KEY | Yes | Tencent Cloud API Secret Key |
TENCENT_COS_BUCKET | Yes | COS bucket name (e.g., my-bucket-1250000000) |
TENCENT_COS_REGION | Yes | COS region (e.g., ap-guangzhou, ap-nanjing) |
TENCENT_COS_PATH | No | Upload path prefix (default: uploads/) |
| Option | Description |
|---|---|
| -------- | ------------- |
--secret-id | Tencent Cloud API Secret ID |
--secret-key | Tencent Cloud API Secret Key |
--bucket | COS bucket name |
--region | COS region |
--path | Upload path prefix |
upload_{timestamp}_{random}.{ext}共 1 个版本