图片上传功能是我们web里面经常用到的,获得的方式也有很多种,这里我用的是request.getInputStream()获取文件流的方式。想要获取文件流有两种方式,附上代码

int length = request.getContentLength();//获取请求参数长度。
byte[] bytes = new byte[length];//定义数组,长度为请求参数的长度
DataInputStream dis = new DataInputStream(request.getInputStream);//获取请求内容,转成数据输入流
int readcount = 0;//定义输入流读取数
while(readcount < length){
int aa= dis.read(bytes,readcount,length); //读取输入流,放入bytes数组,返回每次读取的数量
readcount = aa + readcount; //下一次的读取开始从readcount开始
}
//读完之后bytes就是输入流的字节数组,将其转为字符串就能看到
String bb = new String(bytes,"UTF-8");

上面这种是利用读取输入流的方式,也可以用写入字节输入流的方式获取,就不需要获取请求长度了

DataInputStream dis = new DataInputStream(request.getInputStream());
ByteArrayOutputStream baot = new ByteArrayOutputStream();
byte[] bytes = new byte[1024]; //定义一个数组 用来读取
int n = 0;//每次读取输入流的量
while((n=dis.read(bytes))!=-1){
baot.write(bytes); //将读取的字节流写入字节输出流
}
byte[] outbyte = boat.toByteArray();//将字节输出流转为自己数组。
String bb = new String(outbyte,"UTF-8");

这两种方式都能获取传输的内容,但有两点一定要注意一下,最开始在获取的时候只能获取到文件的名字却没有文件的内容,这里附上测试用的前端代码:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAs8AAABqCAIAAADMXiuUAAAgAElEQVR4nO2d2XMaSb7v/efcmIKArKKiqGYJlkCIQCDUYhNawkjWbqF9t5b2bsnyhmxZ2JKFZYEWZDWS8djYlrrV3e7pPp5zZjvREz0nbk9Mnxuht3sf7vu9D4VLpaJACIEW9+8TPGQlmb9MEirzW5m/TM5gAAAAAAAA+eTMcVcAAAAAAIBPnDM4kDsUJZZUr+OuGgAABwbuaADIFaA2cgn0TQDwKQF3NADkClAbuQT6JgD4lIA7GgByBaiNXAJ9EwB8SsAdDQC5AtRGLoG+CQA+JeCOBoBcAWojl0DfBACfEnBHA0CuALWRS9ie6PGMauALPRPovKCHvgkATiNwRwNArgC1kUuYjqlryPD//v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Y7diY2drSbei4lHUtHSROkvr+r++aoucsdOSEXcxBKJKHjN9surutiUi41nYn7/0B0eL/kpWjPUrOeWa9QS7x57ClNXDAAAAACAE0VKtfHVE0+tS5kqm1Yp/evzakY6cEme2/APFU0NF1GEWE1Ln90ouT9kYeLVtHRnq+nZWMnV9gIFJfnj0lkMw2RIvLPVNNxsMOuIna2mi60FJp3s1zcNPJu1LuXWE88BPykAAAAAAMfDGQcHLHluQyM8hfDoonW8x5Qcn6w2/hzx6pSJtRijhvhzxMtN3FWjTWUhOZAwoiXePfaYdLIMPh0AAAAAAMdPNn4bNCn5c8RLEmIsiWS18eubBnbTikQi+le8Pk1ibD+1wfhtpNJAAAAAAACcQLLZk3Kn33y7X2BiAxMSEH99Xs3untUopP/O2RZ7ULUBe1IAAAAA4DSyj9rAks7bQFLRH5e9lExgYkMpl+5sNcn37oANfGG91WeSITFJiP1DRdc7E46lNCnZ2WpSUJJkC0q5FMMwbgD7eN5Gqr24AAAAAACcWPZXG9jes0SvtBX4LxQlpxHckIJhGEWIn991/PN1/U/rNZNDRWKRKE1ibgw3gMFZogAAAABwatnjJcr6iqYhHijjTUgAAAAAAACkgT+3AQAAAAAAkFtAbQAAAAAAkF9AbQAAAAAAkF9AbQAAAAAAkF8OpjY+t32Wk1eePgwAAAAAACcQUBsAAAAAAOQXUBsAAAAAAOQXUBsAAAAAAOSX/w87kOtle2cUvgAAAABJRU5ErkJggg==" alt="" />

上网查了一下,有的人是input标签里面没有name属性会导致这个问题,但是我并不是没有name标签。继续查是这样的:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhkAAACBCAIAAADi0j/bAAAPSElEQVR4nO2dQZLkNg5Ffac8tc/iu9ib0Wo2s3BOhYoAPj5FZSpV9V4oJpQkCIAgAXS1e7L++Oc//22fP//62xHj4eHh4fmdzx+OEL2Eh4eHh0c8f/z51988PDw8PDwrzx8bAADAGvQSAABYhV4CAACr0EsAAGAVegkAAKxCLwEAgFXoJQAAsAq9BAAA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DErou1E0glONb4ScKEkBmRK4V5MBySKDUbb613p9HFMOKuG5fsb6NxbrbaKfxyZuj9bdsrm4cJ7eN/PJeJWtavaW/X1bqaEKelb19f6WEnaywg/xV4qha2f5i788VShr7MajAc0pVDoiatEMIXpVsyncubYfRhWte4duGOptngiwsP9Szr7eDz+gc/g/F4yWzX0wtnrbo4fdlIPHkjg+DFmSxSu/Pen9NYco1PjK2uFz2mIppzXRp2plPWF1VS8QtWgY86XdwKoxYaR9jJXiTBs9uoSCk/O/3dcYlaLndJLdCmflZxyKda11uF2ykzgKYVVTKL+1IE4Xjk5SK6sFVtLZdadFxZnp6Z0HrhdGr2kDUg1XsX5YeA4Fk1U8leXUHhyTi9JT7q6QOZljYPtrfLHpxKmtV6lol6i92K67aRumr3DibTOfCziyGbX7scPnM57dJon3t6H4WIIySlXWx7ZbRwEBj/13q8uofCE73aEe/NY6CWfxq2dv4qrSyg8oZfAXUn/4Ew5/m1cXULhCb0EAG7M1SUUntBLAODGXF1C4Qm9BABuzNUlFJ7QSwDgxlxdQuEJvQQAbszVJRSe0EsA4MZcXULhCb0EAG7M1SUUntBLAODGXF1C4Qm9BABuzNUlFJ7QSwDgxlxdQuEJvQQAbszVJRSe0EsA4MZcXULhCb0EAG7M1SUUntBLAODGXF1C4Qm9BABuzNUlFJ78DxNz5OU6KB34AAAAAElFTkSuQmCC" alt="" />

所以我觉得肯定是缺少了发送类型所以在form标签中加入了enctype='multipart/form-data',果然可以获取内容了。

然后就是第二个问题,也是我们通过request.getInputStream()方法获取文件的话,获取的内容不只是只有文件的,即使你表单中只有一个file标签。刚开始我就是犯了这个错误,用拿到的byte数组直接输入或者转成文件都是显示不出来,后来才意识到,拿到了inputStream的bytes还要把文件的内容从中剥离出来才可以。这里提供一个方法,具体实现过程还没有细研究,先附上之后再细看

/**
* 取得图片数据
*
* @param requestData
* @param contentType
* @return
* @throws IOException
*/
private byte[] getImgData(byte[] requestData, String contentType)
throws IOException {
String txtBody = new String(requestData, "GBK");
if (!txtBody.contains("image/jpg") && !txtBody.contains("image/jpeg")&& !txtBody.contains("jpg")) {
return null;
}
String boundarytext = contentType.substring(
contentType.lastIndexOf("=") + 1, contentType.length());
// 取得实际上传文件的起始与结束位置
int pos = txtBody.indexOf("filename=\"");
pos = txtBody.indexOf("\n", pos) + 1;
pos = txtBody.indexOf("\n", pos) + 1;
pos = txtBody.indexOf("\n", pos) + 1;
// 文件描述信息后就文件内容,直到为文件边界为止,从pos开始找边界
int boundaryLoc = txtBody.indexOf(boundarytext, pos) - 4;
ByteArrayOutputStream realdatas = null;
try {
int begin = ((txtBody.substring(0, pos)).getBytes("GBK")).length;
int end = ((txtBody.substring(begin, boundaryLoc)).getBytes("GBK")).length;
realdatas = new ByteArrayOutputStream();
realdatas.write(requestData, begin, end);
return realdatas.toByteArray();
} finally {
if (null != realdatas) {
try {
realdatas.close();
} catch (IOException e) {
logger.error("处理上传图片数据错误:", e);
}
}
}
}

这里的参数就是请求的内容数组bytes以及请求类型,类型的话我们可以通过request.getContentType()方法直接获取,返回值同样是byte数组,返回的byte数组就是我们上传图片的内容了。

返回前端的话,直接利用response就可以。

OutputStream os = response.getOutputStream();
os.write(bytes);

图片上传利用request.getInputStream()获取文件流时遇到的问题的更多相关文章

  1. Jquery图片上传组件,支持多文件上传

    Jquery图片上传组件,支持多文件上传http://www.jq22.com/jquery-info230jQuery File Upload 是一个Jquery图片上传组件,支持多文件上传.取消. ...

  2. 链接ftp,把文件或图片上传到ftp指定的文件夹中

    /******************************************************************** *  * * Filename : .java * Auth ...

  3. 图片上传利用<iframe></iframe>标签实现无刷新上传图片

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 图片上传怎么用File接受文件

    xl_echo编辑整理,欢迎转载,转载请声明文章来源.欢迎添加echo微信(微信号:t2421499075)交流学习. 百战不败,依不自称常胜,百败不颓,依能奋力前行.——这才是真正的堪称强大!! - ...

  5. 从request中获取文件流的两种方式,配置文件上传大小

    原文地址:https://blog.csdn.net/xyr05288/article/details/80692132

  6. 利用layui的load模块解决图片上传

    首先肯定要参考layui官网的upload模块文档:http://www.layui.com/doc/modules/upload.html 讲讲思路:在一份添加表单中,我们有个图片上传的模块,然后我 ...

  7. 富文本编辑器 KindEditor 的基本使用 文件上传 图片上传

    富文本编辑器 KindEditor 富文本编辑器,Rich Text Editor , 简称 RTE , 它提供类似于 Microsoft Word 的编辑功能. 常用的富文本编辑器: KindEdi ...

  8. 百度ueditor的图片上传,前后端交互使用

    百度ueditor的使用 一个文本编辑器,看了网上很多文档写的很乱,这里拾人牙慧,整理下怎么使用. 这个东西如果不涉及到图片附件上传,其实很简单,就是几个前端文件,直接引用,然后配置下ueditor. ...

  9. TP5图片上传

    /*图片上传*/ public function upload(){ // 获取表单上传文件 例如上传了001.jpg $file = request()->file('file'); // 移 ...

随机推荐

  1. shell 函数的高级用法

    函数介绍 linux shell中的函数和大多数编程语言中的函数一样 将相似的任务或者代码封装到函数中,供其他地方调用 语法格式 如何调用函数 shell终端中定义函数 [root@master da ...

  2. 元组和range

    元组 只读列表,不支持增 删 改:但是元组里的列表可以增删改 元组其实就是通过逗号(,)设定的,和小括号并没有什么必然的关系,所以当元组只有一个元素的时候,需要在元素后加个逗号 存储大量数据,有序.不 ...

  3. C# - 常见问题整理

    关于循环和try{}..catch{}的嵌套使用 foreach(var item in items) { try { try{ } catch(Exception ex) { throw; // 将 ...

  4. KubeEdge,一个Kubernetes原生边缘计算框架

    ​KubeEdge成为第一个Kubernetes原生边缘计算平台,Edge和云组件现已开源! 开源边缘计算正在经历其业界最具活力的发展阶段.如此多的开源平台,如此多的整合以及如此多的标准化举措!这显示 ...

  5. SpringBoot之多数据源动态切换数据源

    原文:https://www.jianshu.com/p/cac4759b2684 实现 1.建库建表 首先,我们在本地新建三个数据库名分别为master,slave1,slave2,我们的目前就是写 ...

  6. 用js刷剑指offer(二叉树中和为某一值的路径)

    题目描述 输入一颗二叉树的根节点和一个整数,打印出二叉树中结点值的和为输入整数的所有路径.路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径.(注意: 在返回值的list中,数组长度大 ...

  7. 《3+1团队》第七次作业:团队项目设计完善&编码

    项目 内容 这个作业属于哪个课程 任课教师博客主页链接 这个作业的要求在哪里 作业链接地址 团队名称 3+1团队 团队博客地址 https://home.cnblogs.com/u/3-1group ...

  8. Robot Framework--接口测试环境搭建

    1.安装requests库 (robotframework-requests依赖这个request http client) 执行pip install requests 2. 安装requestLi ...

  9. flask中使用ajax 处理前端请求,每隔一段时间请求一次

    需求: flask中使用ajax 处理前端请求,每隔一段时间请求一次,并展示在页面 使用 setInterval(function(){},1000)方法 结果展示: html:(test.html) ...

  10. Cache 和 Buffer 的区别在哪里

    Cache和Buffer是两个不同的概念,简单的说,Cache是加速“读”,而buffer是缓冲“写”,前者解决读的问题,保存从磁盘上读出的数据,后者是解决写的问题,保存即将要写入到磁盘上的数据.在很 ...