As part of a Document
You can add attachments to a Document. Saving the document will add the attachment.
String name = "java-log.png"; Document d = new Document(); InputStream is = TestClass.class.getResourceAsStream("/fixtures/image.png"); d.addAttachment(name, is); database.saveDocument(d); Document d2 = database.fetchDocument(d.getId()); Attachment a = d2.getAttachment(name);
With an existing document:
Document d = database.fetchDocument(docId); Attachment a = d.getAttachment("logo.png"); // Replace existing attachment d.addAttachment("logo.png", new FileInputStream("logo2.png")); // Add another attachment d.addAttachment(new File("docs.tex")); // This will use the file name as the attachment name ServerResponse response = database.saveDocument(d);
If this is an existing document and there already is an attachment with this name, the attachment will be replaced.
Comments (0)
Anonymous replies:
Help Tips
- Text formatting
- Headings
- Lists
Full notation guide*bold*bold_italic_italich1.Large headingh5.Small heading*Bulleted point#Numbered point