【发布时间】:2017-12-02 13:48:55
【问题描述】:
我正在实现一个多米诺网络服务提供者,其目的是从 base64 格式流式传输,在使用网络服务的客户端中是一个附件文件,将其转换回文件。在用 java 开发的 web 服务提供者中,我使用 Stream 类和 Mime 类来转换流和文件。 Web 服务提供程序适用于最大为 5 MB 的文件,对于较大的文件,将显示错误 technote。有人遇到过这个问题吗?有什么办法解决吗?
这是网络服务提供者的代码
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)
{
}
}
}
【问题讨论】:
-
您是否查看过 Domino 服务器的服务器文档中的“请求内容的最大大小”设置以及相应网站配置文档中的“最大 POST 数据”设置?有关说明,请参见此处:ibm.com/support/knowledgecenter/en/SSKTMJ_8.5.3/…
-
两个参数都设置为 10 MB。
标签: web service stream lotus-domino