附件的临时文件夹 [英] Temporary folder for attachments

查看:25
本文介绍了附件的临时文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些临时文件以后会变成附件(通过embedObject)最好放什么地方?是否有任何可用于此目的的 xpages 临时文件夹?

What is the best place to put some temporary files that will become attachments later(by means of embedObject)? Are there any temporary folders for xpages that can be obtained and used for this purpose?

或者有没有办法在不使用中间文件的情况下从流创建附件?

Or is there a way to create atachments from stream without use of intermediary files?

推荐答案

您可以使用 MIMEEntity 执行类似的操作.然后您将能够将附件直接流式传输到您的笔记文档中.您将必须获得对notesdocument 和包含文件内容的输出流的句柄.然后,您可以尝试执行我在此处的代码片段中所做的操作.

You can do something like this with the MIMEEntity. Then you will be able to stream an attachment right into your notesdocument. You will have to get a handle to a notesdocument and an outputstream with the file content. Then you can try to do something like I have done in the code snippet here.

        MIMEEntity m = newDoc.createMIMEEntity( fieldNameForFiles );
        MIMEHeader header = m.createHeader("content-disposition");
        header.setHeaderVal("attachment;filename=\"" + this.getFileName() + "\"");
        Stream oStream = session.createStream();
        InputStream is = new ByteArrayInputStream( ((ByteArrayOutputStream)outStream).toByteArray() );
        oStream.setContents(is);
        m.setContentFromBytes(oStream, "application/pdf", MIMEEntity.ENC_IDENTITY_BINARY); 
        m.decodeContent();
        newDoc.save(true, true);

这篇关于附件的临时文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆