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
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);