Namespaces
ovok.documents
Register uploads, update metadata, delete documents, and build download URLs.
- Stable unknown
- Release candidate since 0.4.49-rc.4
- Development since 0.4.49-dev.517+4645a0a
Uploaded documents. Uploading is two steps: register the document with the API, then send the file to the pre-signed target it returns.
Upload a file
const doc = await ovok.documents.createUpload({
fileName: 'report.pdf',
contentType: 'application/pdf',
isPublic: false,
});
if (doc.uploadOptions) {
const form = new FormData();
for (const [name, value] of Object.entries(doc.uploadOptions.fields)) form.append(name, value);
form.append('file', file);
await fetch(doc.uploadOptions.url, { method: 'POST', body: form });
}createUploadonly registers the document. The file goes straight to the storage URL; the SDK does not send it.- Put the
filefield last in the form, as pre-signed POST targets expect. replaceUpload(documentId, body)registers a new file for an existing document. It takes the samefileName,contentTypeandisPublic.
List and change documents
const documents = await ovok.documents.list();
await ovok.documents.updateMetadata(documentId, metadata);
await ovok.documents.delete(documentId);listtakes an optional search query and returns the server's envelope.- Calls routes under
document.
Build download URLs
const url = ovok.documents.downloadUrl(documentId, { width: 400 });
const publicUrl = ovok.documents.publicDownloadUrl(publicToken);- Both methods build a URL and make no request.
downloadUrlneeds the bearer token: fetch it with the session's token, and it redirects to a signed URL. It cannot be used as an<img src>.publicDownloadUrlneeds no bearer, so it fits an image or media element. The token comes from a document registered withisPublic: true.width,heightandfitresize image downloads.
Reference
- documents API reference: every method and type.
- Errors and retries
Last updated on