{"id":19990111,"url":"https://github.com/futuweb/cossync","last_synced_at":"2026-01-27T11:13:24.150Z","repository":{"id":55388804,"uuid":"73143492","full_name":"futuweb/cossync","owner":"futuweb","description":"腾讯云COS同步（批量上传）工具","archived":false,"fork":false,"pushed_at":"2024-07-29T02:18:41.000Z","size":68,"stargazers_count":25,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T03:46:08.441Z","etag":null,"topics":["cli","cos","qcloud","storage","sync"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/futuweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-08T03:01:34.000Z","updated_at":"2024-07-24T09:02:41.000Z","dependencies_parsed_at":"2024-05-14T11:40:55.656Z","dependency_job_id":"0f39fb91-c15f-4d9b-9af7-6607e5114da4","html_url":"https://github.com/futuweb/cossync","commit_stats":{"total_commits":53,"total_committers":10,"mean_commits":5.3,"dds":0.5849056603773585,"last_synced_commit":"c1808b5b3cd2658ee11cc50de28a21293ab89618"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/futuweb/cossync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuweb%2Fcossync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuweb%2Fcossync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuweb%2Fcossync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuweb%2Fcossync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/futuweb","download_url":"https://codeload.github.com/futuweb/cossync/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuweb%2Fcossync/sbom","scorecard":{"id":414902,"data":{"date":"2025-08-11","repo":{"name":"github.com/futuweb/cossync","commit":"c1808b5b3cd2658ee11cc50de28a21293ab89618"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":3,"reason":"Found 6/18 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 19 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T23:34:53.264Z","repository_id":55388804,"created_at":"2025-08-18T23:34:53.264Z","updated_at":"2025-08-18T23:34:53.264Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28812372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T07:41:26.337Z","status":"ssl_error","status_checked_at":"2026-01-27T07:41:08.776Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cos","qcloud","storage","sync"],"created_at":"2024-11-13T04:50:59.792Z","updated_at":"2026-01-27T11:13:24.129Z","avatar_url":"https://github.com/futuweb.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# 腾讯云COS （V3，V5 BUCKET）文件夹同步（批量上传）工具\n支持V3，V5版本的bucket。\n\n腾讯云文档： [https://cloud.tencent.com/document/product/436/12264](https://cloud.tencent.com/document/product/436/12264)\n\n## 安装\n\ncmd:\n\n```sh\nnpm install -g cossync\n```\n\nrequire:\n\n```sh\nnpm install --save cossync\n```\n\n## CLI配置\n\n准备一个配置文件，例如`conf.json`：\n\n```json\n// V3 BUCKET\n{\n    \"appId\":\"100012345\",\n    \"secretId\":\"ABCDABCDABCDABCDABCDABCD\",\n    \"secretKey\":\"abcdabcdabcd\",\n    \"expired\":1800,\n    \"bucket\":\"bucketName\",\n    \"remotePath\":\"/test/\",\n    \"localPath\":\"./\",\n    \"maxAge\":31536000,\n    \"strict\":true ,\n    \"timeout\":30,\n    \"mime\":{\n        \"default\": true,\n        \".test\": \"text/plain\"\n    }\n}\n\n//v5 bucket\n{\n    \"secretId\":\"SGFDDGHFGFHHSEREWTRETRETER\",\n    \"secretKey\":\"FGHGFHGFHGFHAASRETRET\",\n    \"bucket\":\"testname-12500000\",\n    \"strict\":true,\n    \"version\":\"v5\",\n    \"region\":\"na-ashburn\",\n    \"remotePath\":\"/test/\",\n    \"localPath\": \"./test\",\n    \"maxAge\":31536000, //cache-control\n    \"expires\": 300, //content -expries\n    \"timeout\": 120000, // 单个文件上传超时时间，单位为ms\n    \"mime\":{  //content-type\n        \"default\": true,\n        \".test\": \"text/plain\"\n    },\n    \"globConfig\":{\n      \"ignore\":[\"node_modules/**\"],\n      \"nodir\":true\n    }\n}\n```\n\nV3 BUCKET配置项说明：\n\n* `bucket` COS bucket名称\n* `expired` 密钥有效期，单位s\n* `strict` 单个文件出错是否停止上传，默认值`true`\n* `localPath` 为本地要同步的文件的根目录。`localPath`中的内容将被一一同步到`remotePath`中\n* `remotePath` 腾讯COS存储根目录，以`/`开头和结尾 。例如：`/test/`。目前只支持一级\n* `maxAge` 设置`cache-control`头为指定的`max-age`值\n* `mime` 中的`default`表示是否让cossync模块根据后缀名解析MIME（使用`mime`模块），其它键值表示需要自定义MIME\n* `timeout` 连接超时时间，单位s\n\n\nV5 BUCKET 特殊配置项说明：\n\n* `bucket` 格式为 {bucket}-{appid}\n* `version` 指定使用的cos版本。 目前只有： `v3` 和 `v5`。\n* `region`  表示bucket的所属地域。\n* `globConfig`  参考[node-glob](https://github.com/isaacs/node-glob) 。 主要用于配置筛选上传文件。\n* `timeout` 连接超时时间，单位ms，默认为120000ms\n\n## CLI使用\n如果没有指定使用的配置文件，将在`proccess.cwd()`目录下寻找`cossyncconf.json`文件。\n\n```sh\ncossync conf.json\n```\n\n## V5 模块API\n\n### `Cossync(options)`\n\n构建函数，返回`Cossync`实例。\n\n参数：\n\n* `options`参数对象\n    * `secretId` COS  secretId\n    * `secretKey` COS secretKey\n    * `bucket` COS {bucket}-{appid}\n    * `strict` 单个文件出错是否停止上传，默认值`true`\n    * `remotePath` 腾讯COS存储根目录，以`/`开头和结尾 。例如：`/test/`。目前只支持一级\n    * `progress` 上传进度回调函数\n    * `timeout` 单个文件超时时间，默认值`120000`ms\n    * `skipWhenExist` 默认值为false则上传所有文件，值为true则跳过已上传的文件\n\n\n`progress(data)`参数：\n\n* `data.success` 成功文件个数\n* `data.fail` 失败文件个数\n* `data.total` 总文件个数\n* `data.successList`  成功列表\n* `data.failList`  失败列表\n\n### Cossync#sync(localPath [,globConfig [,callback]])\n实例方法，收集上传文件并上传文件接口。\n\n### Cossync#upload(localPath , files)\n上传文件接口。\n\n\n### V5 bucket 案例\n\n```js\nvar cossync = require('cossync').cossync;\n\nvar conf = {\n    secretId:'DGFDFGDFGDFGDF',\n    secretKey:'DFGDFGDFGDFGDFGDFDFGDFG',\n    bucket:'ertretretr-12500000',\n    strict:true,\n    skipWhenExist:true,\n    version:'v5',\n    region:'na-ashburn',\n    remotePath:'/test/',\n    localPath: '/data',\n    timeout: 120000, // 单个文件上传超时时间，单位毫秒，默认为2分钟\n    maxAge:31536000, //cache-control\n    expires: 300, //content -expries\n    mime:{  //content-type\n        default: true,\n        \".test\": \"text/plain\"\n    },\n    globConfig:{\n      ignore:[\"node_modules/**\"],\n      nodir:true\n    }\n};\n\nvar cos = cossync(conf);\n\ncos.sync(conf.localPath , conf.globConfig , function(err , result){\n  console.log(err , result);\n});\n```\n\n返回：\n\n```js\n{total: files.length || 0 , success:0 , fail:0 , successList:[] , failList:[]};\n```\n\n## V3 模块API\n\n### `Cossync(options)`\n\n构建函数，返回`Cossync`实例。\n\n参数：\n\n* `options`参数对象\n    * `appId` COS AppId\n    * `secretId` COS  secretId\n    * `secretKey` COS secretKey\n    * `expired` 密钥有效期，单位s\n    * `bucket` COS bucket名称\n    * `maxAge` 设置`cache-control`头为指定的`max-age`值\n    * `timeout` 连接超时时间，单位s\n    * `strict` 单个文件出错是否停止上传，默认值`true`\n    * `remotePath` 腾讯COS存储根目录，以`/`开头和结尾 。例如：`/test/`。目前只支持一级\n    * `progress` 上传进度回调函数\n    * `timeout` 单个文件超时时间，单位毫秒，默认为120000ms（2分钟）\n\n`progress(data)`参数：\n\n* `data.success` 成功文件个数\n* `data.fail` 失败文件个数\n* `data.total` 总文件个数\n\n### Cossync#sync(localPath [,mimeConf [,maxAge[,callback]]])\n\n实例方法，上传文件接口。\n\n*  `localPath` [\\\u003cString\\\u003e](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String) 本地上传的文件目录 必须存在\n*  `mimeConf` [\\\u003cObject\\\u003e](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object) 后缀名，见CLI配置项解释 可选\n*  `maxAge` [\\\u003cNumber\\\u003e](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number) 缓存有效期 可选\n*  `callback` [\\\u003cFunction\\\u003e](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function) 上传结束回调函数 可选\n\n`callback(err, result)`，如果上传失败`result`参数为空，`err`为`Error`实例；成功，`err === undefined` ， `result`参数会返回相应的上传状态。\n\n`result`参数如下：\n\n```js\n{\n    code: 0,\n    files:\n    [ 'demo_001.html',\n      'demo_002.html',\n      'demo_003.html'\n    ],\n    localPath: 'E:/source/2016_11/4/demo/',\n    remotePath: '/test/',\n    bucket: 'bug',\n    count: {\n        total: 3,\n        success: 3,\n        fail: 0\n    }\n}\n```\n\n### V3 bucket 案例\n\n```javascript\nvar cossync = require('cossync').cossync;\n\nvar conf = {\n    \"appId\":\"100012345\",\n    \"secretId\":\"ABCDABCDABCDABCDABCDABCD\",\n    \"secretKey\":\"abcdabcdabcd\",\n    \"expired\":1800,\n    \"bucket\":\"bucketName\",\n    \"remotePath\":\"/test/\",\n    \"localPath\":\"./\",\n    \"maxAge\":31536000,\n    \"strict\":true ,\n    \"timeout\":30,\n    \"mime\":{\n        \"default\": true,\n        \".test\": \"text/plain\"\n    }\n}\n\nvar cos = cossync(conf);\n\ncos.sync(conf.localPath conf.mime, conf.maxAge || conf.cacheMaxAge || 0, function(err , result){\n    console.log(err , result);\n});\n```\n\n## Cossync.setBrowserLog(false|true)\n\n静态方法，浏览器环境中（如electron）是否开户浏览器日志输出。默认关闭。\n\n## 历史\n\n### 1.7.0 2024-07-24\n- v5支持UseAccelerate参数，控制是否支持开启加速域名，默认为false则不开启，true则开启加速域名\n\n### 1.6.0 2024-05-11\n- v5支持skipWhenExist参数，默认值为false则上传所有文件，值为true则跳过已上传的文件。\n\n### 1.5.3 2023-08-08\n- 修复V5上传文件名含中文失败的问题\n\n### 1.5.2 2021-01-04\n\n- 去除调试日志\n\n### 1.5.1 2020-05-20\n\n- 修复v5版本log出的速度为NaN的问题，上传数据精确到KB/s\n\n### 1.5.0 2020-02-27\n\n- V5 bucket支持timeout参数，默认为120000ms\n\n### 1.4.3 2019-12-03\n\n- 上传失败时抛出详细异常\n\n### 1.4.0 2018-08-15\n\n- 支持V5 bucket\n- 兼容旧版v3 bucket\n- 修改引入方式\n\n### 1.3.1 2017-03-27\n\n- 优化callback回调\n- 修改=\u003e箭头函数为`function`\n\n### 1.3.0 2017-01-16\n\n- 增加上传进度\n- 增加连接超时设置\n- 增加单个文件报错是否停止上传\n- 兼容浏览器日志打印，完善日志打印\n\n### 1.2.0 2016-11-08\n\n- 增加出错时3次重试\n- 出错时退出返回码改为`1`\n\n### 1.1.0 2016-09-07\n\n- `root`变更为`remotePath`\n- 增加`localPath`选项设置本地目录\n- 增加缓存头控制选项`cacheMaxAge`\n- 增加MIME配置项`mime`\n- 规整控制台输出\n\n### 1.0.1 2016-09-04\n\n- 修复命令行无法使用的问题\n\n### 1.0.0 2016-09-04\n\n- 基本功能实现\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffutuweb%2Fcossync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffutuweb%2Fcossync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffutuweb%2Fcossync/lists"}