public class NodeAttachmentService implements AttachmentStorage, AcceptsFileUpload
Stores attachments in the specified local directory, which must exist. Doesn't allow new attachments to be uploaded.
Constructor and Description |
---|
NodeAttachmentService(java.nio.file.Path storePath,
com.codahale.metrics.MetricRegistry metrics)
Stores attachments in the specified local directory, which must exist. Doesn't allow new attachments to be uploaded.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<java.lang.String> |
getAcceptableFileExtensions()
What file extensions are acceptable for the file to be handed to upload()
|
boolean |
getAutomaticallyExtractAttachments()
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).
|
boolean |
getCheckAttachmentsOnLoad() |
java.lang.String |
getDataTypePrefix()
A string that prefixes the URLs, e.g. "attachments" or "interest-rates". Should be OK for URLs.
|
java.nio.file.Path |
getStorePath() |
SecureHash |
importAttachment(java.io.InputStream jar)
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.
|
Attachment |
openAttachment(SecureHash id)
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.
|
void |
setAutomaticallyExtractAttachments(boolean p)
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).
|
void |
setCheckAttachmentsOnLoad(boolean p) |
java.lang.String |
upload(java.io.InputStream data)
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.
|
importAttachment, openAttachment
getAcceptableFileExtensions, getDataTypePrefix, upload
public NodeAttachmentService(java.nio.file.Path storePath, com.codahale.metrics.MetricRegistry metrics)
Stores attachments in the specified local directory, which must exist. Doesn't allow new attachments to be uploaded.
public boolean getCheckAttachmentsOnLoad()
public void setCheckAttachmentsOnLoad(boolean p)
public boolean getAutomaticallyExtractAttachments()
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).
public void setAutomaticallyExtractAttachments(boolean p)
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).
public Attachment openAttachment(SecureHash id)
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.
public SecureHash importAttachment(java.io.InputStream jar)
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.
Note that you should not pass a JarInputStream into this method and it will throw if you do, because access to the raw byte stream is required.
public java.lang.String getDataTypePrefix()
A string that prefixes the URLs, e.g. "attachments" or "interest-rates". Should be OK for URLs.
public java.util.List<java.lang.String> getAcceptableFileExtensions()
What file extensions are acceptable for the file to be handed to upload()
public java.lang.String upload(java.io.InputStream data)
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.
public java.nio.file.Path getStorePath()