Read multipart/mixed response in Java/Groovy

旧时模样 提交于 2019-11-30 23:41:17

Here is what I did in groovy. Needed java mail library:

//... get reader from response, can use response.success callback in http.request
ByteArrayDataSource ds = new ByteArrayDataSource(new ReaderInputStream(reader), "multipart/mixed");
MimeMultipart multipart = new MimeMultipart(ds);
BodyPart part = multipart.getBodyPart(1);
file = new File('/../../path/filename.pdf')
file << part.content

Have you tried retrieving it from the request?

 CommonsMultipartFile file = request.getFile('myFile') //File
 def offerId = params.offerId //Standard Param
 def index = params.idx //Standard Param

This corresponds to a form input like below:

<input class="invDocUpload" id="invFileUpload" type="file" name="myFile" size="40"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!