{"id":20367406,"url":"https://github.com/aomd/h5-upload","last_synced_at":"2025-07-26T21:11:36.329Z","repository":{"id":147967586,"uuid":"264216514","full_name":"Aomd/h5-upload","owner":"Aomd","description":"支持多文件、分片、断点上传","archived":false,"fork":false,"pushed_at":"2020-09-14T13:03:02.000Z","size":11,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-26T00:51:15.881Z","etag":null,"topics":["ajax","h5","socket","websocket"],"latest_commit_sha":null,"homepage":"","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/Aomd.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":"2020-05-15T14:35:07.000Z","updated_at":"2022-02-14T13:13:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"1c4c8fc2-a5ca-4ef0-8a95-d1b8db17b23c","html_url":"https://github.com/Aomd/h5-upload","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aomd%2Fh5-upload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aomd%2Fh5-upload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aomd%2Fh5-upload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aomd%2Fh5-upload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aomd","download_url":"https://codeload.github.com/Aomd/h5-upload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248521082,"owners_count":21117995,"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":["ajax","h5","socket","websocket"],"created_at":"2024-11-15T00:31:48.450Z","updated_at":"2025-04-12T05:25:32.271Z","avatar_url":"https://github.com/Aomd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fileUpload\n * 只提供到api，与ui分离（解耦）\n * 采用二进制流以及[内置协议](#内置协议)实现上传功能 \n * 支持ajax、websocket\n * 支持多文件、分片、断点上传\n  \n### 内置协议\n二进制流格式\n* [start-16]      字节 数据体字节大小（记录数据体大小）\n* [16-?]          字节 自定义参数格式为json（字节截取后可以转换成json对象）\n* [?-end]         字节 数据体 (分片数据体)\n\n\n## events\n| name     |     Parameters      | Description      |\n|:---------|:-------------------:|:-----------------|\n| start    |     file,files      | 开始事件         |\n| pause    |     file,files      | 暂停事件         |\n| end      |     file,files      | 当前文件上传结束 |\n| progress | file,files,progress | 上传进度         |\n| change   |     file,files      | 文件改变         |\n| error    |        error        | 错误信息         |\n\n\n## methods\n| name                                              | Description |\n|:--------------------------------------------------|:------------|\n| start()                                           | 开始事件    |\n| pause()                                           | 暂停事件    |\n| on([eventname](#events):String, handler:function) | 监听事件    |\n| config(option : [option](#option))                | 参数配置    |\n| addfile(file:File)                                | 添加文件    |\n\n### option\n\n```\n{\n  // 上传类型 \n  type: 'ajax' || 'sock',\n  // 分片大小单位：kb\n  size:  1024,\n  // 上传服务地址\n  url: ''\n}\n```\n\n## Example \n\n```\nvar upload = new fileUpload({\n  url:'wss://127.0.0.1:8055/',\n  type:'sock',\n  // 单位kb\n  size: 1024 \n});\n\nupload.config({\n  url:'http://127.0.0.1:8055/test.php',\n  type:'ajax',\n});\n\n\nupload.addfile(new File([\"one\"], \"one.txt\", {type: \"text/plain\",}))\n\nupload.addfile(new File([\"two\"], \"two.txt\", {type: \"text/plain\",}))\n\n...\n\n// 监听\nupload.on('progress',function(FileInfo, FileList , progress){\n  // code\n\n})\n\n//开始\nupload.start()\n\n\n```\n\n## run demo\n\n```\n// node\n\nbase:\u003enode ./main\nbase:\u003e服务成功开启端口为:7096\nbase:\u003e请访问：http://localhost:7096/example/page/index.html\nbase:\u003enode service 服务启动成功 端口 3000\n\n```\n\n## 目录结构\n\n```\n根目录\n├─ example\n│  ├─ assets        //文件资源\n│  ├─ page          //页面\n│  ├─ service       //后台服务\n├─ fileUpload.js    //核心\n└─ main.js          //node 入口文件\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faomd%2Fh5-upload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faomd%2Fh5-upload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faomd%2Fh5-upload/lists"}