我正在实现一个domino web服务提供者,它的目的是从base64格式中流(在使用web服务的客户机中是一个附件文件),将它转换回一个文件。在java开发的web服务提供者中,我使用Stream类和Mime类来转换流和文件。web服务提供程序可以很好地处理高达5MB的文件,对于更大的文件,则在显示technote时出现错误。有人有这个问题吗?有什么办法可以绕过吗?
以下是web服务提供者的代码
public class criaAnexo {
private Vector itemsToRecycle;
public void attachDocument( byte[] is) {
// creating the output stream used to create the MIME attachments
try
{
itemsToRecycle = new Vector();
Session session = NotesFactory.createSession();
Database db = session.getDatabase("Serverx", "base.nsf");
if (!db.isOpen())
System.out.println("names2.nsf does not exist on snapper");
else
{
Stream outStream = session.createStream();
outStream.write(is);
session.setConvertMIME(false);
// create the MIME body
Document doc = db.createDocument();
doc.replaceItemValue("Form", "formAttachment");
MIMEEntity body = doc.createMIMEEntity();
// create a child for each attachment<br/>
MIMEEntity child = body.createChildEntity();
// find the fileSuffix<br/>
//String fileSuffix = files[i].substring(files[i].lastIndexOf(".")+1);
String fileSuffix = "pdf";
// set the child to the outstream using a mapped MIME type<br/>
// MIME type mapping see: http://www.w3schools.com/media/media_mimeref.asp
//child.setContentFromBytes(outStream, mapMIMEType(fileSuffix), MIMEEntity.ENC_IDENTITY_BINARY);
child.setContentFromBytes(outStream, "application/pdf", MIMEEntity.ENC_IDENTITY_BINARY);
// set name for file attachment<br/>
MIMEHeader header = child.createHeader("Content-Disposition");
header.setHeaderVal("attachment; filename=\"teste.pdf\"");
// set unique id for file attachment to be able to refer to it<br/>
header = child.createHeader("Content-ID");
header.setHeaderVal("teste.pdf");
//outStream.truncate();
//outStream.close();
outStream.close();
Runtime rt = Runtime.getRuntime();
long total_mem = rt.totalMemory();
long free_mem = rt.freeMemory();
long used_mem = total_mem - free_mem;
System.out.println("Total de Memória:"+total_mem);
System.out.println("Total de Memória livre:"+free_mem);
System.out.println("Total de memoria usada pelo agente: " + used_mem/1048576);
doc.save( true, true );
itemsToRecycle.add(doc);
session.recycle(itemsToRecycle); //recycle all items added to vector
session.recycle();
}
}
catch(Exception e)
{
}
}}
发布于 2017-06-30 13:48:46
事实上,这种限制发生在使用我在domino中实现的web服务的客户机中。在对问题的描述中引用的technote暗示问题是站在提供者一边的,但实际上并非如此。当我在点网上实现web服务客户端时,文件是无问题地流的。
发布于 2017-06-29 13:23:29
由于base64编码和其他开销,大于5MB的文件可能超过您为服务器的最大请求内容和最大POST数据设置配置的10 MB限制。试着增加它们。
https://stackoverflow.com/questions/44815319
复制相似问题