我收到了我需要解析的http请求的"multipart/mixed"
响应。响应的一部分是我需要保存到磁盘的pdf文件。是否有任何图书馆会为我做这件事?
答案 0 :(得分:2)
这是我在groovy中所做的。需要的java邮件库:
//... 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
答案 1 :(得分:0)
您是否尝试过从请求中检索它?
CommonsMultipartFile file = request.getFile('myFile') //File
def offerId = params.offerId //Standard Param
def index = params.idx //Standard Param
这对应于下面的表单输入:
<input class="invDocUpload" id="invFileUpload" type="file" name="myFile" size="40"/>