corda / net.corda.node.services.persistence / NodeAttachmentService

# NodeAttachmentService

`@ThreadSafe class NodeAttachmentService : AttachmentStorage, AcceptsFileUpload`

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

### Exceptions

OnDiskHashMismatch | `class OnDiskHashMismatch : Exception`

### Constructors

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

### Properties

acceptableFileExtensions | `val acceptableFileExtensions: List<String>` 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.
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 it's 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): String` 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.

### Inherited Functions

accepts | `open fun accepts(prefix: String): Boolean` Check if this service accepts this type of upload. For example if you are uploading interest rates this could be "my-service-interest-rates". Type here does not refer to file extentions or MIME types.