Tencent COS CLI - Node.js wrapper for tencentyun/coscli, the command-line interface for Tencent Cloud Object Storage.
npm install and it just worksnpm install coscli-bin -D
Or install globally for CLI access:
npm install -g coscli-bin
After installation, you can use the coscli command directly. For detailed CLI usage, please refer to the official coscli documentation.
import coscli from 'coscli-bin';
// Execute commands
await coscli.ls(['cos://mybucket/path/']);
await coscli.cp(['localfile.txt', 'cos://mybucket/path/']);
await coscli.sync(['./local', 'cos://mybucket/path/']);
// Or use exec for more control
import { exec, execWithOutput } from 'coscli-bin';
// Execute with output
await exec('ls', ['cos://mybucket/path/']);
// Capture output
const { stdout } = await execWithOutput('version');
console.log(stdout);
| Variable | Type | Description |
|---|---|---|
COSCLI_OVERRIDE_VERSION | string | Install a different coscli version (ignores package.json) |
COSCLI_SKIP_DOWNLOAD | boolean | Skip the postinstall binary download |
COSCLI_BIN_PATH | string | Use a pre-existing coscli binary |
COSCLI_MIRROR_BASE_URL | string | Custom download mirror URL |
COSCLI_SKIP_CHECKSUM | boolean | Skip SHA-256 checksum verification |
COSCLI_QUIET | boolean | Suppress installation output |
Install a specific version:
COSCLI_OVERRIDE_VERSION=1.0.7 npm install coscli
Skip download (useful for CI):
COSCLI_SKIP_DOWNLOAD=1 npm install
Use a custom binary:
COSCLI_BIN_PATH=/usr/local/bin/coscli npm start
Use a custom mirror:
COSCLI_MIRROR_BASE_URL=https://mirror.example.com/coscli npm install
# Clone the repository
git clone https://github.com/your-org/coscli-npm.git
cd coscli-npm
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
MIT