Giter Site home page Giter Site logo

duolife / uploadfileutil Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 2.0 196 KB

基于org.apache.commons.fileupload。对其进行了一些封装,简单易用。不用再去为了传递文件而用极其繁琐的代码取出请求中的其他参数。

License: Apache License 2.0

Java 100.00%

uploadfileutil's Introduction

UploadFileUtil

基于org.apache.commons.fileupload(http://commons.apache.org/proper/commons-fileupload )。对其进行了一些封装,简单易用。
由于上传文件时,需要设定method=“post”,并且enctype=“multipart/form-data”。
所以,服务端需要做更多的工作来获取文件,也不能使用通常的方法来获取请求参数。
UploadFileUtil就是为了简化这些工作,并且让你更好的专注业务逻辑而非这些细节。
内部逻辑很简单,分而治之,阅读起来会更加清晰明了。

调用UploadFileUtil的getUploadFile2Map(request, response),剩下的一起都交给他就好了。 他会返回一个Map结构,请求参数名称为key,即可取出对应的value。文件也不例外。

所有的文件上传过程都不用再花费过多的精力,只需要
UploadFileUtil uf = new UploadFileUtil();
Map parameter = uf.getUploadFile2Map(request, response);
parameter中包含了全部的上传参数以及文件。

相关参数设置:

Maxsize :文件最大尺寸限制; //默认值为 4 * 1024 * 1024 ; 4MB
allowFileTypes : 允许上传的文件格式; //默认为图片上传 {"jpg", "jpeg", "png","JPG", "JPEG", "PNG"};

uploadfileutil's People

Contributors

duolife avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.