newAttachment

fun newAttachment(path: String, metadata: Map<String, String> = emptyMap()): DittoAttachment?

Deprecated

Moved to store.newAttachment.

Replace with

store.newAttachment

Creates a new attachment, which can then be inserted into a document.

The file residing at the provided path will be copied into the Ditto's store. The DittoAttachment object that is returned is what you can then use to insert an attachment into a document.

You can provide metadata about the attachment, which will be replicated to other peers alongside the file attachment.

Below is a snippet to show how you can use the newAttachment functionality to insert an attachment into a document.

val attachment = collection.newAttachment(fileInputStream)
val docId = collection.insert(mapOf("attachment" to attachment, "other" to "string"))

Return

a DittoAttachment object, which can be used to insert the attachment into a document.

Parameters

path

the path to the file that you want to create an attachment with.

metadata

metadata relating to the attachment.


fun newAttachment(inputStream: InputStream, metadata: Map<String, String> = emptyMap()): DittoAttachment?

Deprecated

Moved to store.newAttachment.

Creates a new attachment, which can then be inserted into a document.

The file that the input stream relates to will be copied into Ditto's store. The DittoAttachment object that is returned is what you can then use to insert an attachment into a document.

You can provide metadata about the attachment, which will be replicated to other peers alongside the file attachment.

Note that the input stream provided will be closed once it has been read from.

Below is a snippet to show how you can use the newAttachment functionality to insert an attachment into a document.

val attachment = collection.newAttachment(fileInputStream)
val docId = collection.insert(mapOf("attachment" to attachment, "other" to "string"))

Return

a DittoAttachment object, which can be used to insert the attachment into a document.

Parameters

inputStream

an input stream for the file that you want to create an attachment with.

metadata

metadata relating to the attachment.