{"id":16183891,"url":"https://github.com/crazymryan/upload-file-service","last_synced_at":"2026-03-05T03:31:52.254Z","repository":{"id":245105093,"uuid":"817257512","full_name":"CrazyMrYan/upload-file-service","owner":"CrazyMrYan","description":"使用 Nodejs + Koa + Sequelize  实现文件上传服务，可图片压缩、生成缩略图、添加水印、防盗链","archived":false,"fork":false,"pushed_at":"2024-07-16T01:19:29.000Z","size":323,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"full/1.0.0","last_synced_at":"2025-07-06T13:02:14.492Z","etag":null,"topics":["file-upload","file-upload-server","file-upload-service","image-thumbnails","mysql2","nodejs","sequelize","sharp","tinify","upload-file-service"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/CrazyMrYan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-06-19T10:34:34.000Z","updated_at":"2024-07-16T01:19:31.000Z","dependencies_parsed_at":"2024-07-16T04:53:52.227Z","dependency_job_id":null,"html_url":"https://github.com/CrazyMrYan/upload-file-service","commit_stats":null,"previous_names":["crazymryan/upload-file-service"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/CrazyMrYan/upload-file-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyMrYan%2Fupload-file-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyMrYan%2Fupload-file-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyMrYan%2Fupload-file-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyMrYan%2Fupload-file-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CrazyMrYan","download_url":"https://codeload.github.com/CrazyMrYan/upload-file-service/tar.gz/refs/heads/full/1.0.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrazyMrYan%2Fupload-file-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30108623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T01:39:18.192Z","status":"online","status_checked_at":"2026-03-05T02:00:06.710Z","response_time":93,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["file-upload","file-upload-server","file-upload-service","image-thumbnails","mysql2","nodejs","sequelize","sharp","tinify","upload-file-service"],"created_at":"2024-10-10T07:07:54.412Z","updated_at":"2026-03-05T03:31:52.236Z","avatar_url":"https://github.com/CrazyMrYan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# upload-file-service\nnodejs 实现文件上传功能\n\n\u003e 注意此项目不在更新（作为基础项目存档），新开了一个组织，有兴趣的小伙伴可以参考 [diskcloud/service](https://github.com/diskcloud/service)，欢迎提ISSUES、PR等，一起建设此项目，\n\u003e\n\n### 支持功能\n\u003e 目前均为免费版本，Plus 版本还在规划中，Lite 和 Full 版本永久免费。\n\n| 功能         | Lite（缩减版） | Full（全量版） | Plus（增强版）      |\n|--------------|----------------|----------------|--------------|\n| 数据出入库   | 否             | 是             | 是           |\n| 缩略图       | 否             | 是             | 是           |\n| 图片压缩     | 是             | 是             | 是           |\n| 返回 md 格式 | 是             | 是             | 是           |\n| 保留原始文件 | 是             | 是             | 是           |\n| 文件水印     | 否             | 是             | 是           |\n| 自动定时备份     | 否             | 否             | 是           |\n| 公开失效时间 | 否             | 否             | 是           |\n| 高级搜索功能 | 否             | 否             | 是           |\n\n[![YouTube](https://img.youtube.com/vi/5w1dCYBrf2k/0.jpg)](https://youtu.be/5w1dCYBrf2k)\n\n### 使用方法\n\n```shell\nyarn install\n\nyarn dev\n```\n\n\u003e 启动完成之后，会自动创建 resource 作为资源文件夹，而 provisional 会作为临时文件夹。后续会考虑开启定时任务进行清理。\n\n### 目录结构\n\n```shell\n├── LICENSE\n├── README.md\n├── constants\n│   └── file.js\n├── index.js\n├── models # 表模型\n│   └── files.js\n├── package.json\n├── public\n│   ├── icons\n│   │   ├── doc.png\n│   │   ├── document.png\n│   │   ├── folders.png\n│   │   ├── pdf.png\n│   │   ├── psd.png\n│   │   ├── shared_folders.png\n│   │   ├── unknown_file_types.png\n│   │   ├── video.png\n│   │   ├── xlsx.png\n│   │   └── zip.png\n│   └── index.html\n├── routers # 路由\n│   └── files.js\n├── utils\n│   ├── createPath.js\n│   ├── dbInstance.js\n│   ├── detectFileType.js\n│   └── responseFormatter.js\n└── yarn.lock\n```\n\n### 环境变量\n创建一个 `.env.local` 文件，在里面配置对应的环境变量\n\n```env\nTINIFY_KEY= #Tinify 压缩图片的key。如果不需要图片压缩则可以不写\nINTERNAL_NETWORK_DOMAIN=http://localhost:3000\nPUBLIC_NETWORK_DOMAIN=http://localhost:3000\nSERVER_PORT=3000\nDIALECT=mysql\nMYSQL_DATABASE=\nMYSQL_HOST=\nMYSQL_USER=root\nMYSQL_PASSWORD=\nMYSQL_PORT=3306\n```\n\n### 创建表的字段说明\n\n\u003e 启动项目则会，自动创建创建 `files` 表结构\n\n```sql\nCREATE TABLE files (\n    id VARCHAR(50) DEFAULT NULL,\n    filename VARCHAR(255) NOT NULL,\n    file_size BIGINT(20) NOT NULL,\n    file_location VARCHAR(255) NOT NULL,\n    created_by VARCHAR(255) NOT NULL,\n    created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,\n    updated_by VARCHAR(255) DEFAULT NULL,\n    updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n    is_public TINYINT(1) DEFAULT '0',\n    public_expiration TIMESTAMP NULL DEFAULT NULL,\n    public_by VARCHAR(255) DEFAULT NULL,\n    is_thumb TINYINT(1) DEFAULT NULL,\n    thumb_location VARCHAR(255) DEFAULT NULL,\n    is_delete TINYINT(1) NOT NULL DEFAULT '0',\n    real_file_location VARCHAR(255) DEFAULT NULL,\n    real_file_thumb_location VARCHAR(255) DEFAULT NULL,\n    mime VARCHAR(255) DEFAULT NULL,\n    ext VARCHAR(50) DEFAULT NULL,\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;\n```\n\n| 列名             | 数据类型       | 是否为空 | 默认值               | 注释                                         |\n|------------------|----------------|----------|----------------------|----------------------------------------------|\n| `id`             | int(11)        | NOT NULL |                      | 文件的唯一标识                                 |\n| `filename`       | varchar(255)   | NOT NULL |                      | 文件名                                       |\n| `file_size`       | bigint(20)     | NOT NULL |                      | 文件大小（以字节为单位）                      |\n| `file_location`   | varchar(255)   | NOT NULL |                      | 文件存储的位置                               |\n| `created_by`     | varchar(255)   | NOT NULL |                      | 创建该文件的用户                             |\n| `created_at`     | timestamp      | NULL     | CURRENT_TIMESTAMP    | 文件的创建时间，默认当前时间                   |\n| `updated_by`     | varchar(255)   | NULL     | NULL                 | 最近更新该文件的用户                         |\n| `updated_at`     | timestamp      | NULL     | CURRENT_TIMESTAMP    | 最近更新的时间，默认当前时间，更新时自动修改  |\n| `is_public`      | tinyint(1)     | NULL     | '0'                  | 是否公开，默认值为0（不公开）                  |\n| `public_expiration` | timestamp   | NULL     | NULL                 | 公开访问的截止时间                           |\n| `public_by`      | varchar(255)   | NULL     | NULL                 | 设置公开的用户                               |\n| `is_thumb`       | tinyint(1)     | NULL     | '0'                  | 是否为缩略图，默认值为0（不是缩略图）          |\n| `thumb_location` | varchar(255)   | NULL     | NULL                 | 缩略图存储的位置                             |\n| `is_delete`      | tinyint(1)     | NOT NULL | '0'                  | 是否被删除，默认值为0（未删除）                |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazymryan%2Fupload-file-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrazymryan%2Fupload-file-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazymryan%2Fupload-file-service/lists"}