{"id":19195682,"url":"https://github.com/searchfe/fis-http-push","last_synced_at":"2025-05-08T23:43:50.214Z","repository":{"id":49250694,"uuid":"249388241","full_name":"searchfe/fis-http-push","owner":"searchfe","description":"FIS http push API","archived":false,"fork":false,"pushed_at":"2022-12-06T01:33:05.000Z","size":1408,"stargazers_count":5,"open_issues_count":7,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-08T23:43:42.965Z","etag":null,"topics":["fis","fsr","http","push"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/searchfe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-23T09:32:51.000Z","updated_at":"2021-11-02T11:39:03.000Z","dependencies_parsed_at":"2023-01-24T08:15:44.422Z","dependency_job_id":null,"html_url":"https://github.com/searchfe/fis-http-push","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/searchfe%2Ffis-http-push","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/searchfe%2Ffis-http-push/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/searchfe%2Ffis-http-push/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/searchfe%2Ffis-http-push/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/searchfe","download_url":"https://codeload.github.com/searchfe/fis-http-push/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166474,"owners_count":21864467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["fis","fsr","http","push"],"created_at":"2024-11-09T12:11:09.668Z","updated_at":"2025-05-08T23:43:50.199Z","avatar_url":"https://github.com/searchfe.png","language":"TypeScript","readme":"# fis-http-push\n[![npm version](https://img.shields.io/npm/v/fis-http-push.svg)](https://www.npmjs.org/package/fis-http-push)\n[![downloads](https://img.shields.io/npm/dm/fis-http-push.svg)](https://www.npmjs.org/package/fis-http-push)\n[![Build Status](https://travis-ci.com/searchfe/fis-http-push.svg?branch=master)](https://travis-ci.com/searchfe/fis-http-push)\n[![Coveralls](https://img.shields.io/coveralls/searchfe/fis-http-push.svg)](https://coveralls.io/github/searchfe/fis-http-push?branch=master)\n[![dependencies](https://img.shields.io/david/searchfe/fis-http-push.svg)](https://david-dm.org/searchfe/fis-http-push)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/searchfe/fis-http-push)\n[![GitHub issues](https://img.shields.io/github/issues-closed/searchfe/fis-http-push.svg)](https://github.com/searchfe/fis-http-push/issues)\n[![David](https://img.shields.io/david/searchfe/fis-http-push.svg)](https://david-dm.org/searchfe/fis-http-push)\n[![David Dev](https://img.shields.io/david/dev/searchfe/fis-http-push.svg)](https://david-dm.org/searchfe/fis-http-push?type=dev)\n[![DUB license](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/searchfe/fis-http-push/blob/master/LICENSE)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits)\n\nFIS HTTP Push SDK, 用于 push 文件到 Fis Secure Receiver（新版的 fis http-push）。\n\n## 编程接口\n\n编程接口主要包括 `fcp`, `push`, `pushFile` 三个接口，都返回 `Promise\u003cvoid\u003e`。\n其中 fcp 是高度封装的接口，支持单个文件、多个文件、文件夹：\n\n```javascript\nconst {fcp} = require('fis-http-push');\n\n// 单文件\nfcp('./main.js', '/var/www/main.js', {receiver: 'http://example.com:8210'})\n// 文件夹\nfcp('./dist/', '/var/www/main.js', {receiver: 'http://example.com:8210', recursive: true})\n```\n\n`push` 和 `pushFile` 是细粒度的接口，用来完成文件到文件的任务。不支持文件夹，但可以为每个 SOURCE 定义上传的 DEST。\n\n```javascript\nconst {push, pushFile} = require('fis-http-push');\nconst options = {receiver: 'http://example.com:8210'};\n\n// 单个文件\npushFile('./main.js', '/var/www/main.js', options);\n// 一组任务\npush([{source: './main.js', dest: '/var/www/main.js'}], options);\n```\n\n`options` 中可以包含如下参数：\n\n* receiver `string`：服务端接收 URL，例如：http://example.com:8210\n* logLevel `number`：日志级别（0-6），默认为 LogLevel.INFO(2)。0 为 DEBUG，6 为 NONE。\n* recursive `boolean`：是否递归，默认为 false。SOURCE 为目录时必须指定。\n* retry `number`：重试次数，默认为 3。\n* fastFail `boolean`：是否在第一个错误时退出，默认为 false。\n* concurrent `number`：并发数，默认为 100\n* parallelPushCount `number`：concurrent 的别名，兼容旧版配置。\n* readEmail `(savedEmail: string) =\u003e Promise\u003cstring\u003e`：自定义读取用户邮箱的方法。\n* readCode: `() =\u003e Promise\u003cstring\u003e`：自定义读取验证码的方法。\n\n## 命令行接口\n\n安装：\n\n```bash\nnpm install -g fis-http-push@latest\n```\n\n上传：\n\n```bash\nfcp foo.txt http://example.com:8210/tmp/foo.txt\n```\n\n帮助：\n\n```\n\u003e fcp --help\nfcp \u003cSOURCE..\u003e \u003cDEST\u003e\n\nPositionals:\n  SOURCE..  source file or directory            [array]\n  DEST      destination                         [string]\n\nOptions:\n  --version        Show version number          [boolean]\n  --help           Show usage instructions.     [boolean]\n  --recursive, -r  push directories recursively [boolean]\n  --concurrent, -c max concurrent http request  [number]\n  --loglevel, -l   0,1,2,3,4,5,6                [number]\n  --quiet, -q      print nothing, equiv -l 6    [boolean]\n  --debug, -d      debug mode, equiv -l 0       [boolean]\n\nExamples:\n  fcp ./a.txt http://example.com:8210/tmp/a.txt  a.txt -\u003e /tmp/a.txt\n  fcp -r ./dir http://example.com:8210/tmp/dir   dir -\u003e /tmp/dir\n  fcp -r ./dir http://example.com:8210/tmp/dir/  dir -\u003e /tmp/dir/dir\n  fcp a.txt b.txt http://example.com:8210/tmp/   {a,b}.txt -\u003e /tmp/{a,b}.txt\n```\n\n\u003e fcp 还有 fhp, fis-http-push 两个别名，随意选用。\n\n## Makit 中使用\n\n```javascript\nconst {makit} = require('fis-http-push');\nrule('http://example.com:8210/tmp/foo.txt', 'foo.txt', makit())\n\n// 使用方式：\n// makit http://example.com:8210/tmp/foo.txt\n```\n\n[demo](https://github.com/searchfe/fis-http-push/tree/master/demo) 目录包含了一个在 makit 中使用 fis-http-push 的例子。\n\n## 多个 SOURCE\n\n类似 scp，我们可以指定多个 SOURCE，比如：\n\n```bash\nfcp ./main.js ./foo.js ./bar.js http://example.com:8210/var/www/\n```\n\n对应的编程接口为：\n\n```javascript\nconst {fcp} = require('fis-http-push');\n\nfcp(\n    ['./main.js', './foo.js', './bar.js'],\n    '/var/www/',\n    {receiver: 'http://example.com:8210'}\n)\n```\n\n## 文件夹上传\n\n如果 SOURCE 是一个文件夹，或者 SOURCE 中存在文件夹时，必须添加 `-r` 参数。fcp 会递归地上传其中的文件和文件夹，比如：\n\n```bash\nfcp -r foo/ http://example.com:8210/tmp/foo\n```\n\n对应的编程接口的参数是 `recursive`：\n\n```javascript\nconst {fcp} = require('fis-http-push');\n\nfcp('./src/', '/var/www/', {receiver: 'http://example.com:8210', recursive: true})\n```\n\n## 创建父目录\n\n当 DEST 以 `/` 结尾时 DEST 会被当做父目录，且不存在时会被创建。例如：\n\n```bash\n# 将会同步到 /tmp/dist，例如 ./src/a.js -\u003e /tmp/dist/a.js\nfcp -r ./src/ http://example.com:8210/tmp/dist\n# 将会同步到 /tmp/dist/src/，例如 ./src/a.js -\u003e /tmp/dist/src/a.js\nfcp -r ./src/ http://example.com:8210/tmp/dist/\n```\n\n```javascript\nconst {fcp} = require('fis-http-push');\n\n// 将会同步到 /tmp/dist，例如 ./src/a.js -\u003e /tmp/dist/a.js\nfcp('./src/', '/tmp/dist', {receiver: 'http://example.com:8210', recursive: true})\n// 将会同步到 /tmp/dist/src/，例如 ./src/a.js -\u003e /tmp/dist/src/a.js\nfcp('./src/', '/tmp/dist/', {receiver: 'http://example.com:8210', recursive: true})\n```\n\n注意：存在多个 SOURCE 时无论 DEST 是否以 `/` 结尾都会被当做父目录。\n\n## 开发指南\n\n运行测试：\n\n```bash\nnpm install\nnpm test\n```\n\n### 打日志\n\n1. 生产环境日志请使用 `/src/util/log`；\n2. 开发环境日志请使用 `import {debug} from './util/log'` 并 `export DEBUG=fhp`。\n\n### 文件 Mock\n\n提供了 test/stub/fs.ts，使用示例见 test/makit.spec.ts。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsearchfe%2Ffis-http-push","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsearchfe%2Ffis-http-push","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsearchfe%2Ffis-http-push/lists"}