{"id":15211389,"url":"https://github.com/normangyllenhaal/file-upload","last_synced_at":"2025-07-08T01:39:12.739Z","repository":{"id":57743352,"uuid":"88337239","full_name":"NormanGyllenhaal/file-upload","owner":"NormanGyllenhaal","description":"spring mvc java upload file 上传插件","archived":false,"fork":false,"pushed_at":"2017-05-14T12:07:39.000Z","size":15,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T23:22:39.958Z","etag":null,"topics":["java","springmvc","upload-file"],"latest_commit_sha":null,"homepage":"","language":"Java","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/NormanGyllenhaal.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}},"created_at":"2017-04-15T09:27:27.000Z","updated_at":"2022-07-03T04:35:26.000Z","dependencies_parsed_at":"2022-08-26T01:42:53.932Z","dependency_job_id":null,"html_url":"https://github.com/NormanGyllenhaal/file-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/NormanGyllenhaal%2Ffile-upload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NormanGyllenhaal%2Ffile-upload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NormanGyllenhaal%2Ffile-upload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NormanGyllenhaal%2Ffile-upload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NormanGyllenhaal","download_url":"https://codeload.github.com/NormanGyllenhaal/file-upload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250419258,"owners_count":21427567,"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":["java","springmvc","upload-file"],"created_at":"2024-09-28T08:40:25.817Z","updated_at":"2025-04-23T10:43:18.879Z","avatar_url":"https://github.com/NormanGyllenhaal.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"### java springmvc 上传插件 file upload\n\n[![Build Status](https://travis-ci.org/NormanGyllenhaal/file-upload.svg?branch=master)](https://travis-ci.org/NormanGyllenhaal/file-upload)\n        \n- 插件功能  \n   单个或多个文件上传  \n   同步异步文件处理  \n   校验文件后缀    \n   校验文件头  \n   保存文件到指定目录，并返回文件的url  \n   支持图片压缩  \n \n- 在spring mvc 中使用\n1. 首先加入maven依赖 ，已加入maven中央仓库 http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22top.javatool.fileuplod%22\n\n- maven 依赖\n```xml\n\u003cdependency\u003e\n       \u003cgroupId\u003etop.javatool.fileuplod\u003c/groupId\u003e\n       \u003cartifactId\u003efile-upload\u003c/artifactId\u003e\n       \u003cversion\u003e1.0\u003c/version\u003e\n  \u003c/dependency\u003e\n```\n2. bean 注入\n```xml\n\u003cbean id=\"fileupload\" class=\"top.javatool.fileupload.FileUpload\"\np:filePath=\"/data/www/\" \np:filePrefix=\"test/\" \np:fileType=\"jpg,gif,png,bmp,jpeg\" \np:fileHeader=\"FFD8FF,89504E47,47494638,49492A00,424D\"\np:host=\"www.test.com\"\np:ip=\"\"\n/\u003e\n```\n\n3. 代码中使用\n```java\n@org.springframework.beans.factory.annotation.Autowired\nprivate FileUpload fileUpload;\n\n  \n@org.springframework.web.bind.annotation.RequestMapping(value = \"upload\")\npublic void testUpload(MultipartFile file,HttpServletRequest request){\n    //保存文件到指定路径并返回图片url\n    String imageUrl = fileUpload.saveFile(file,request);\n    //http://www.test.com/test/yyyy-MM-dd/随机数字（时间戳+6位随机数).文件后缀\n}\n```\n\n4. 参数说明\n\n- filePath 文件保存到的服务器路径，如不存在自动创建（必须）\n- filePrefix 文件保存到的服务器路径前缀 就是在filePath 之后加上相应的路径  \n- fileType 允许上传的文件后缀，如不符合返回异常   \n- fileHeader 允许的文件头 \n- host 图片保存的域名 \n- ip 提供 ip到host 的转换 可以在在本机配置host 文件配置 相应规则  \n如 0.0.0.0 www.test.com     \n这样在进行多个域名服务器时部署时会比较方便  如果ip存在则不启用host\n\n\n  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnormangyllenhaal%2Ffile-upload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnormangyllenhaal%2Ffile-upload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnormangyllenhaal%2Ffile-upload/lists"}