# koofr cheatsheet
Every export of @deckyard/koofr. Guides are listed in the introduction .
jennifer import "@deckyard/koofr/" as koofr;
Every function that sends a request throws Error{kind: "koofr"} when it fails. A mountId comes from mounts or primaryMount; a path is absolute in its mount (/docs/a.txt, / for the root). Times are milliseconds since the epoch.
# Constants
Constant Value Meaning ERROR_KIND"koofr"the kind of every error the deck throws DEFAULT_URL"https://app.koofr.net"Koofr's own service DOWNLOAD_LIMIT67108864the largest body get accepts with maxBytes 0 (64 MiB) REPLY_LIMIT67108864the largest reply body of every other request with Client.replyLimit 0 (64 MiB) MAX_RETRIES10the most retries withRetries accepts SEARCH_MAX1000the most results one search asks for MAX_PAGES1000pages trashAll follows before it refuses FILE_TYPES["file", "folder", "pdf", "document", "sheet", "presentation", "archive", "code", "text", "audio", "video", "image"]the values of SearchOptions.fileType
# Types
A literal of a deck struct names every field, so build PutOptions and SearchOptions from the zero value: def o as koofr.PutOptions; then set fields.
# Client
Field Meaning url as stringhttps://host[:port][/path], without /api/v2.1auth as stringthe Authorization header value; "" for none tls as http.TlsOptionscertificate checking timeoutMs as intidle timeout per request; 0 for 30 s, never negative retries as intretries of a GET answered 429 or 5xx, 0 to MAX_RETRIES replyLimit as intthe largest reply body of every request but get; 0 for REPLY_LIMIT, negative for none plainHttp as boolsend credentials over http:// to a host that is not loopback
Build a Client with client and the with* functions, not a literal.
# User
Field Meaning id as stringthe user id firstName as stringthe first name lastName as stringthe last name email as stringthe e-mail address level as intthe account level Koofr reports
# Mount
Field Meaning id as stringthe mount id name as stringthe name, e.g. Koofr type as stringe.g. device or export origin as stringe.g. hosted, dropbox, share owner as stringthe owner's name isPrimary as boolwhether it is the account's primary storage isShared as boolwhether it is shared with others online as boolwhether it can be reached canWrite as boolwhether the account may change it canUpload as boolwhether the account may upload to it spaceTotal as intthe quota as Koofr reports it (the API description names no unit); 0 when unreported spaceUsed as intthe space used, in the unit of spaceTotal overQuota as boolwhether it is over its quota
# File
Field Meaning name as stringthe name; "" for the root of a mount path as stringthe path in its mount type as stringfile or dirsize as intbytes; 0 for a folder modified as intthe modification time contentType as stringthe media type; "" for a folder hash as stringthe content hash (MD5); "" for a folder
# PutOptions
Field Meaning overwrite as boolreplace an existing file autorename as boolstore under a free name when the name is taken overwriteIfHash as stringreplace only if the existing file has this hash; "" for no condition overwriteIfModified as intreplace only if the existing file has this time; 0 for no condition overwriteIgnoreNonexistent as boolwith a condition, create the file when there is none modified as intthe modification time to set; 0 for now
The zero value refuses an existing file (HTTP 409).
# SearchOptions
Field Meaning offset as intresults to skip limit as intresults to return, up to SEARCH_MAX; 0 for Koofr's default (256) mountId as stringonly this mount; "" for all path as stringonly below this folder; needs mountId contentType as stringonly this media type fileType as stringone of FILE_TYPES; "" for any tags as list of stringonly files with these tags, key=value with a non-empty key
# SearchHit
Field Meaning mountId as stringthe mount it is on path as stringthe path in that mount name as stringthe name type as stringfile or dirsize as intbytes modified as intthe modification time contentType as stringthe media type score as floatthe relevance
# Link
Field Meaning id as stringthe link id name as stringthe name of what it points at mountId as stringthe mount path as stringthe path in the mount url as stringthe link shortUrl as stringthe short form of the link counter as inthow often it was opened hasPassword as boolwhether it asks for a password downloadable as boolwhether visitors may download message as stringthe message shown to visitors created as intwhen it was made validFrom as int0 for no start validTo as int0 for no end
# Receiver
Field Meaning id as stringthe receiver id name as stringthe name of the folder mountId as stringthe mount path as stringthe folder in the mount url as stringthe link shortUrl as stringthe short form of the link counter as inthow often it was used hasPassword as boolwhether it asks for a password alert as boolwhether the owner is told of uploads message as stringthe message shown to visitors created as intwhen it was made validFrom as int0 for no start validTo as int0 for no end
# TrashFile
Field Meaning mountId as stringthe mount it was deleted from path as stringits path there name as stringthe name size as intbytes deleted as intwhen it was deleted contentType as stringthe media type versionId as stringthe deleted version
# TrashPage
Field Meaning files as list of TrashFilethe files cursor as stringthe cursor of the next page; "" on the last retentionDays as inthow long the trash keeps a file
# Connecting
Function Returns Does koofr.client(baseUrl)Clienta client without credentials; refuses a URL with a query, fragment or user, a scheme other than http/https, no host or a bad port koofr.withAppPassword(c, email, password)Clientauthenticate with an app password (HTTP Basic) koofr.withToken(c, token)Clientauthenticate with a bearer token koofr.withPlainHttp(c)Clientallow credentials over http:// to a host that is not loopback koofr.withCaCert(c, pem)Clienttrust a PEM certificate (bytes); undoes withInsecure koofr.withInsecure(c)Clientaccept any certificate koofr.withTimeout(c, ms)Clientset the idle timeout; refuses a negative ms koofr.withRetries(c, n)Clientretry GETs answered 429 or 5xx, n 0 to MAX_RETRIES; not get koofr.withReplyLimit(c, maxBytes)Clientcap the reply body of every request but get; 0 for REPLY_LIMIT, negative for none koofr.call(c, method, path, body)json.Valueany endpoint under /api/v2.1; method GET, POST, PUT, PATCH or DELETE; body is JSON text
# Account
Function Returns Does koofr.user(c)Userthe credentials' account koofr.limits(c)json.Valuethe account's limits, as Koofr sends them (no struct) koofr.mounts(c)list of Mountstorage, devices and shared folders koofr.mount(c, id)Mountone mount koofr.primaryMount(c)Mountthe account's primary storage
# Files
Function Returns Does koofr.info(c, mountId, path)Fileone file or folder koofr.exists(c, mountId, path)boolfalse on HTTP 404 with Koofr's JSON error and code NotFound or none; any other 404 throws koofr.listFolder(c, mountId, path)list of Filethe entries of a folder; throws on an entry name that is not a file name koofr.listRecursive(c, mountId, path)list of Fileeverything below a folder, the folder first; throws on an item path that does not lie below it koofr.mkdir(c, mountId, path)- make a folder in an existing parent koofr.mkdirAll(c, mountId, path)- make a folder and its missing parents; 1 request when it exists koofr.get(c, mountId, path, maxBytes)bytesdownload; maxBytes caps the body, 0 for DOWNLOAD_LIMIT, negative for none koofr.put(c, mountId, path, data, opts)Fileupload as a raw application/octet-stream body; the folder must exist; refuses a reply without a file name koofr.remove(c, mountId, path)- move a file or folder to the trash; not / koofr.rename(c, mountId, path, name)- rename in place; not / koofr.copy(c, mountId, path, toMountId, toPath)stringcopy, also to another mount; the copy's name koofr.move(c, mountId, path, toMountId, toPath)stringmove, also to another mount; the new name
# Search
Function Returns Does koofr.search(c, query, opts)list of SearchHitsearch names across mounts
# Public links
Function Returns Does koofr.links(c, mountId)list of Linkthe links of a mount koofr.allLinks(c)list of Linkthe links of every mount koofr.createLink(c, mountId, path)Linkshare a file or folder koofr.link(c, mountId, id)Linkone link koofr.deleteLink(c, mountId, id)- delete a link koofr.setLinkPassword(c, mountId, id, password)Linkask visitors for a password koofr.clearLinkPassword(c, mountId, id)Linkremove the password koofr.setLinkValidity(c, mountId, id, validFrom, validTo)Linklimit when it works; replaces both bounds, 0 for none; refuses a negative bound or an end not after the start
# Receivers
Function Returns Does koofr.receivers(c, mountId)list of Receiverthe receivers of a mount koofr.allReceivers(c)list of Receiverthe receivers of every mount koofr.createReceiver(c, mountId, path)Receiverlet others upload into a folder koofr.receiver(c, mountId, id)Receiverone receiver koofr.deleteReceiver(c, mountId, id)- delete a receiver koofr.setReceiverPassword(c, mountId, id, password)Receiverask uploaders for a password koofr.clearReceiverPassword(c, mountId, id)Receiverremove the password koofr.setReceiverValidity(c, mountId, id, validFrom, validTo)Receiverlimit when it accepts uploads; replaces both bounds, 0 for none; refuses a negative bound or an end not after the start
# Trash
Function Returns Does koofr.trash(c, cursor)TrashPageone page of up to 1000 files by name, ascending; cursor "" for the first koofr.trashAll(c)list of TrashFileevery page; stops at a cursor it followed before koofr.undelete(c, files)- restore these files; refuses an empty list koofr.undeleteAll(c)- restore everything koofr.emptyTrash(c)- delete the trash for good