Build an attach plan for local files
ztAttachPlan.RdProduces one attach row per local file for the guarded flow:
zotPreview(), zotApprove(), zotExecute() and zotVerify(). Files
whose MD5 is already an attachment of the same parent are omitted.
Arguments
- config
A
zotConfig()object.- files
A data.table with
pathandparentKey(NAfor a standalone attachment) and, optionally,filename,contentTypeandcharset;NAin an optional column takes the default.- library
"user"or a group id.
Details
Every file is checked before any request: a missing or empty file is
refused with a zotPlanError. Each row records the file's md5 and
filesize, so the approval of its preview binds the exact bytes. The stored
filename is cleaned with ztCleanName(); contentType and charset
default to the choice ztAttach() documents. The path is kept as given,
and a relative path is resolved against the working directory of execution.
Planning reads the children of each distinct parent once through
zotListItems() and omits the rows whose MD5 is already attached there,
with a message per omitted file. A parent whose children exceed one listing
page is refused with a zotBoundError, because the omission could not see
every attachment. Standalone files are not compared. Planning does not
write.
See also
ztAttach(), zotPreview(), and zotExecute().
Examples
Path <- tempfile(fileext = ".md")
writeLines("# Notes", Path)
Performer <- function(config, method, path, query, body, version) {
list(status = 200L,
headers = list(`total-results` = "0", `last-modified-version` = "7"),
body = list())
}
Config <- zotConfig(userID = "42", key = "example", performer = Performer)
Files <- data.table::data.table(path = Path, parentKey = "PARENT1")
Plan <- ztAttachPlan(Config, files = Files, library = "user")
Plan$payload[[1L]]$contentType
#> [1] "text/markdown"
unlink(Path)