### Install COSCMD from source Source: https://github.com/tencentyun/coscmd/blob/master/README.rst Use this command to install the tool manually from the source code directory. ```bash python setup.py install ``` -------------------------------- ### Install COSCMD via pip Source: https://github.com/tencentyun/coscmd/blob/master/README.rst Use this command to install or upgrade the coscmd package from PyPI. ```bash pip install -U coscmd ``` -------------------------------- ### Initialize COSCMD Configuration Source: https://context7.com/tencentyun/coscmd/llms.txt Sets up access credentials and connection parameters for COS. Configuration is saved to ~/.cos.conf. Supports various options including custom endpoints and temporary keys. ```bash coscmd config -a AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ -s xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ -b examplebucket-1250000000 \ -r ap-guangzhou ``` ```bash coscmd config -a AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ -s xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ -b examplebucket-1250000000 \ -e cos.accelerate.myqcloud.com ``` ```bash coscmd config -a AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ -s xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ -b examplebucket-1250000000 \ -r ap-beijing \ -m 10 \ -p 20 \ --retry 5 \ --timeout 120 ``` ```bash coscmd config -a AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ -s xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \ -t SecurityTokenxxxxxxxx \ -b examplebucket-1250000000 \ -r ap-shanghai ``` ```bash # 配置文件内容示例 (~/.cos.conf) # [common] # secret_id = AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # secret_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # bucket = examplebucket-1250000000 # region = ap-guangzhou # max_thread = 5 # part_size = 1 # retry = 5 # timeout = 60 # schema = https # verify = md5 # anonymous = False ``` -------------------------------- ### List Files and Directories with COSCMD Source: https://context7.com/tencentyun/coscmd/llms.txt Lists files and directories in the bucket. Supports recursive listing (-ar), limiting results (-n), human-readable sizes (--human), and viewing version history (-v). ```bash coscmd list ``` ```bash coscmd list images/ ``` ```bash coscmd list -ar ``` ```bash coscmd list -n 50 ``` ```bash coscmd list -ar ``` ```bash coscmd list --human images/ ``` ```bash coscmd list -v documents/ ``` ```bash coscmd list -arv ``` ```bash # 输出示例: # images/ DIR # documents/ DIR # example.txt 1024 STANDARD 2024-01-15 10:30:45 # largefile.zip 104857600 STANDARD 2024-01-14 15:20:30 # Files num: 2 # Files size: 104858624 ``` -------------------------------- ### Manage Versioning Source: https://context7.com/tencentyun/coscmd/llms.txt Commands to check and update the versioning status of a bucket. ```bash coscmd getbucketversioning ``` ```bash coscmd putbucketversioning Enabled ``` ```bash coscmd putbucketversioning Suspended ``` -------------------------------- ### Manage Buckets Source: https://context7.com/tencentyun/coscmd/llms.txt Commands for creating and deleting buckets, including forced deletion options. ```bash coscmd createbucket ``` ```bash coscmd deletebucket ``` ```bash coscmd deletebucket -f ``` ```bash coscmd -b newbucket-1250000000 -r ap-guangzhou createbucket ``` -------------------------------- ### Test COS Connection Performance Source: https://context7.com/tencentyun/coscmd/llms.txt Use the probe command to test upload and download bandwidth with configurable file sizes and iteration counts. ```bash # 默认连接测试(3 次,1MB 文件) coscmd probe # 指定测试次数 coscmd probe -n 10 # 指定测试文件大小(MB) coscmd probe -s 10 # 完整测试(10 次,50MB 文件) coscmd probe -n 10 -s 50 ``` -------------------------------- ### Retrieve File Information Source: https://context7.com/tencentyun/coscmd/llms.txt Commands to fetch detailed metadata for objects, including size and storage class. ```bash coscmd info example.txt ``` ```bash coscmd info --human largefile.zip ``` -------------------------------- ### Manage Multipart Uploads Source: https://context7.com/tencentyun/coscmd/llms.txt Commands to list and abort incomplete multipart upload tasks to manage storage usage. ```bash coscmd listparts ``` ```bash coscmd listparts uploads/ ``` ```bash coscmd abort ``` ```bash coscmd abort uploads/ ``` -------------------------------- ### Generate Pre-signed URLs Source: https://context7.com/tencentyun/coscmd/llms.txt Commands to create temporary access URLs for objects with specific expiration times. ```bash coscmd signurl example.txt ``` ```bash coscmd signurl -t 3600 documents/report.pdf ``` ```bash coscmd signurl -t 604800 downloads/software.zip ``` -------------------------------- ### Download Files with COSCMD Source: https://context7.com/tencentyun/coscmd/llms.txt Supports single file, directory recursion, and incremental sync. Use --delete with -rs for full synchronization. Overwrite existing files with -f. Specify version IDs for specific file versions. ```bash coscmd download example.txt /data/example.txt ``` ```bash coscmd download backup/document.pdf /data/downloads/document.pdf ``` ```bash coscmd download -r images/ /data/images/ ``` ```bash coscmd download -rs project/ /data/project/ ``` ```bash coscmd download -rs --delete website/ /data/website/ ``` ```bash coscmd download -rf backup/ /data/backup/ ``` ```bash coscmd download --versionId CAEQMxiBxxxxxxxxxxxxxxxxxxxxxxxx example.txt /data/example.txt ``` ```bash coscmd download -r --include "*.pdf,*.doc" documents/ /data/docs/ ``` ```bash coscmd download -r --ignore "*.tmp,*~" data/ /data/local/ ``` ```bash coscmd download -r --skipmd5 bigdata/ /data/bigdata/ ``` ```bash coscmd download -n 20 largefile.zip /data/largefile.zip ``` ```bash coscmd download -ry --delete sync/ /data/sync/ ``` -------------------------------- ### Copy Files and Directories Source: https://context7.com/tencentyun/coscmd/llms.txt Commands for copying files within or across buckets, including recursive, incremental, and metadata-modifying operations. ```bash coscmd copy examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/source.txt dest.txt ``` ```bash coscmd copy -r examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/source_dir/ dest_dir/ ``` ```bash coscmd copy examplebucket-1250000000.cos.ap-beijing.myqcloud.com/data.txt backup/data.txt ``` ```bash coscmd copy otherbucket-1250000000.cos.ap-guangzhou.myqcloud.com/file.txt imported/file.txt ``` ```bash coscmd copy -rs examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/src/ dst/ ``` ```bash coscmd copy -rs --delete examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/master/ replica/ ``` ```bash coscmd copy -d Replaced -H '{"Content-Type":"application/json"}' \ examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/data.txt data_new.txt ``` ```bash coscmd copy -f examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/update.txt update.txt ``` ```bash coscmd copy -r --include "*.jpg,*.png" \ examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/media/ images/ ``` -------------------------------- ### Move Files and Directories Source: https://context7.com/tencentyun/coscmd/llms.txt Commands to move files between locations, which effectively performs a copy followed by a deletion of the source. ```bash coscmd move examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/old_path/file.txt new_path/file.txt ``` ```bash coscmd move -r examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/temp/ archive/ ``` ```bash coscmd move examplebucket-1250000000.cos.ap-beijing.myqcloud.com/data.txt local_copy.txt ``` ```bash coscmd move -r --include "*.log" \ examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/logs/ archive/logs/ ``` ```bash coscmd move -r --ignore "*.tmp,*.bak" \ examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/project/ backup/project/ ``` -------------------------------- ### Upload Files with COSCMD Source: https://context7.com/tencentyun/coscmd/llms.txt Supports single file, directory recursion, incremental sync, and custom headers. Use --delete with -rs for full synchronization. Filters can be applied using --include and --ignore. ```bash coscmd upload /data/example.txt example.txt ``` ```bash coscmd upload /data/document.pdf backup/2024/document.pdf ``` ```bash coscmd upload -r /data/images/ images/ ``` ```bash coscmd upload -rs /data/project/ project/ ``` ```bash coscmd upload -rs --delete /data/website/ website/ ``` ```bash coscmd upload -H '{"Content-Type":"image/jpeg","Cache-Control":"max-age=31536000"}' \ /data/photo.jpg images/photo.jpg ``` ```bash coscmd upload -r --include "*.jpg,*.png,*.gif" /data/media/ media/ ``` ```bash coscmd upload -r --ignore "*.tmp,*.log,.git/*" /data/code/ code/ ``` ```bash coscmd upload -r --skipmd5 /data/bigdata/ bigdata/ ``` ```bash coscmd upload -f /data/largefile.zip archive/largefile.zip ``` ```bash coscmd -s upload -r /data/batch/ batch/ ``` -------------------------------- ### Manage Access Control Lists (ACL) Source: https://context7.com/tencentyun/coscmd/llms.txt Commands to view and modify access permissions for buckets and individual objects. ```bash coscmd getbucketacl ``` ```bash coscmd putbucketacl --grant-read 1234567890 ``` ```bash coscmd putbucketacl --grant-full-control 1234567890/9876543210 ``` ```bash coscmd putbucketacl --grant-read anyone ``` ```bash coscmd getobjectacl example.txt ``` ```bash coscmd putobjectacl --grant-read 1234567890 example.txt ``` ```bash coscmd putobjectacl --grant-read anyone documents/public.pdf ``` ```bash coscmd putobjectacl --grant-read 1234567890,9876543210 \ --grant-write 1234567890 \ data.txt ``` -------------------------------- ### Run COSCMD via Docker Source: https://context7.com/tencentyun/coscmd/llms.txt Execute COSCMD commands using the official Docker image to avoid local Python dependencies. Useful for CI/CD pipelines and containerized environments. ```bash # 查看版本 docker run --rm -it tencentcom/tencentyun-coscmd --version # 查看帮助 docker run --rm -it tencentcom/tencentyun-coscmd -h # 配置并上传文件(挂载本地目录和配置文件) docker run --rm -it \ -v ~/.cos.conf:/root/.cos.conf \ -v /data:/data \ tencentcom/tencentyun-coscmd upload /data/file.txt file.txt ``` -------------------------------- ### Restore Archived Files Source: https://context7.com/tencentyun/coscmd/llms.txt Commands to restore objects from ARCHIVE or DEEP_ARCHIVE storage classes with various speed and duration options. ```bash coscmd restore archive/data.tar.gz ``` ```bash coscmd restore -d 30 archive/important.zip ``` ```bash coscmd restore -t Expedited archive/urgent.dat ``` ```bash coscmd restore -t Bulk -d 7 archive/batch_data.tar ``` ```bash coscmd restore -r archive/2023/ ``` ```bash coscmd restore -r -d 14 -t Standard archive/monthly_backup/ ``` -------------------------------- ### Delete Files with COSCMD Source: https://context7.com/tencentyun/coscmd/llms.txt Supports deleting single files, recursively deleting directories, and deleting specific versions. Use -f or -y to skip confirmation prompts. Use --versions to delete all versions. ```bash coscmd delete example.txt ``` ```bash coscmd delete -f obsolete.txt ``` ```bash coscmd delete -r old_backup/ ``` ```bash coscmd delete -rf temp/ ``` ```bash coscmd delete --versionId CAEQMxiBxxxxxxxxxxxxxxxxxxxxxxxx example.txt ``` ```bash coscmd delete -r --versions archive/ ``` ```bash coscmd delete -ry logs/2023/ ``` -------------------------------- ### Copy Files with COSCMD Source: https://context7.com/tencentyun/coscmd/llms.txt Copies files within or across COS buckets and regions. Supports incremental synchronization and metadata overwriting. === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.