Temporary folder for attachments

前端 未结 1 485
小鲜肉
小鲜肉 2020-12-22 12:19

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 obtain

相关标签:
1条回答
  • 2020-12-22 12:35

    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);
    
    0 讨论(0)
提交回复
热议问题