往网页分批推送数据:boundary=end,总头-->分头-->body
@getmapping("/test")
public void testjpg(httpservletresponse response) throws ioexception{
response.setcontenttype("multipart/x-mixed-replace;boundary=end");
// set the content type based on the file type you need to download
string contenttype = "content-type: image/jpeg";
// list of files to be downloaded
list
files = new arraylist();
files.add(new file("c:\\users\\administrator\\desktop\\qq\\51.jpg"));
files.add(new file("c:\\users\\administrator\\desktop\\qq\\52.jpg"));
files.add(new file("c:\\users\\administrator\\desktop\\qq\\53.jpg"));
servletoutputstream out = response.getoutputstream();
// print the boundary string
out.println();
out.println("--end");
for(int i =0;i<500;i ) {
for (file file : files) {
// get the file
fileinputstream fis = null;
try {
fis = new fileinputstream(file);
} catch (filenotfoundexception fnfe) {
// if the file does not exists, continue with the next file
system.out.println("could not find file " file.getabsolutepath());
continue;
}
bufferedinputstream fif = new bufferedinputstream(fis);
// print the content type
out.println(contenttype);
out.println("content-disposition: attachment; filename=" file.getname());
out.println();
system.out.println("sending file " file.getname());
// write the contents of the file
int data = 0;
while ((data = fif.read()) != -1) {
out.write(data);
}
fif.close();
try {
thread.sleep(500);
} catch (interruptedexception e) {
e.printstacktrace();
}
// print the boundary string
out.println();
out.println("--end");
out.flush();
system.out.println("finished sending file " file.getname());
}
}
// print the ending boundary string
out.println("--end--");
out.flush();
out.close();
}
相关推荐
c#没有现成的multipart/form-data库,自己封的一个demo供参考。
使用indy自带的idhttp控件,用form表单(multipart/form-data)形式上传文件(图片,视频等)
用c语言实现multipart/form-data文件上传,没有用到curl之类的库。之前做个小的日志上传程序写的。
解决上传文件enctype= multipart/form-data 时无法传递其他参数的问题,以及项目全局编码问题。用的插件是commons io commons fileupload
解决当form的enctype="multipart/form-data" 时request.getparameter()获取不到值的方法 ?
使用c#实现的httpclient拼接multipart/form-data形式参数post提交数据,包含图片内容,有需要的可以下载,希望能帮到有需要的人,
1.sendnotification.jsp:发送通知页面,表单提交数据的类型为multipart/x-www-form-urlencoded 2.recvnotification.jsp:接收通知页面 3.页面简单使用了bootstrap样式 4.开发工具使用idea
servlet上传 enctype="multipart/form-data" servlet上传 enctype="multipart/form-data
c#模拟post发送json和multipart/form-data格式
android模拟 http multipart/form-data 请求协议信息实现图片上传
c#下post 发送 multipart/form-data和json数据
我们知道在通过post方式向服务器发送ajax请求时最好要通过设置请求头来指定为application/x-www-form-urlencoded编码类型。知道通过表单上传文件时必须指定编码类型为"multipart/form-data"。那么为什么要这么设置呢
c#post multipart/form-data和json数据
webapi通过multipart/form-data方式同时上传文件以及数据包含客户端上传例子
解决当form的enctype="multipart/form-data" 时action方法或者控制层用request.getparameter()获取不到值的方法 ?
该程序是 multipart/form-data 远程dos利用程序,一台电脑直接打崩一台服务器!程序只为便于检测你服务器漏洞,切勿非法使用。 检测效果不明显的话,多运行几个实例将会增强攻击力度。
今天小编就为大家分享一篇python处理multipart/form-data的请求方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
<form method="post" enctype="multipart/form-data"> file类型职务的普通参数传递到后台问题解决