com.r3corda.node.services.persistence / NodeAttachmentService

# NodeAttachmentService

`class NodeAttachmentService : AttachmentStorage, AcceptsFileUpload`

Stores attachments in the specified local directory, which must exist. Doesnt allow new attachments to be uploaded.

### Exceptions

OnDiskHashMismatch | `class OnDiskHashMismatch : Exception`

### Constructors

<init> | `NodeAttachmentService(storePath: Path, metrics: <ERROR CLASS>)` Stores attachments in the specified local directory, which must exist. Doesnt allow new attachments to be uploaded.

### Properties

acceptableFileExtensions | `val acceptableFileExtensions: <ERROR CLASS>` What file extensions are acceptable for the file to be handed to upload()
automaticallyExtractAttachments | `var automaticallyExtractAttachments: Boolean` If true, newly inserted attachments will be unzipped to a subdirectory of the storePath. This is intended for human browsing convenience: the attachment itself will still be the file (that is, edits to the extracted directory will not have any effect).
checkAttachmentsOnLoad | `var checkAttachmentsOnLoad: Boolean`
dataTypePrefix | `val dataTypePrefix: String` A string that prefixes the URLs, e.g. "attachments" or "interest-rates". Should be OK for URLs.
metrics | `val metrics: <ERROR CLASS>`
storePath | `val storePath: Path`

### Functions

importAttachment | `fun importAttachment(jar: InputStream): SecureHash` Inserts the given attachment into the store, does not close the input stream. This can be an intensive operation due to the need to copy the bytes to disk and hash them along the way.
openAttachment | `fun openAttachment(id: SecureHash): Attachment?` Returns a handle to a locally stored attachment, or null if its not known. The handle can be used to open a stream for the data, which will be a zip/jar file.
upload | `fun upload(data: InputStream): <ERROR CLASS>` Accepts the data in the given input stream, and returns some sort of useful return message that will be sent back to the user in the response.