The uploader knows the size of every file before it sends it: the browser's File object has size in bytes. Keep a running total in the coach and refuse uploads past the limit - no CMIS query needed:
// UI Toolkit File Uploader "on file selected" / "before upload" event (older toolkits: wrap the input in a custom view)
var LIMIT = 10 * 1024 * 1024; // 10 MB
var total = ${Total}.getData() || 0; // hidden number control / tw.local.uploadedBytes
var f = event && event.file ? event.file : me.context.element.querySelector("input[type=file]").files[0];
if (total + f.size > LIMIT) {
${Msg}.setText("Attachments would exceed 10 MB (" + Math.round((total + f.size) / 1048576 * 10) / 10 + " MB)");
return false; // cancels the upload on toolkits that support it
}
// after a successful upload ("on upload"): ${Total}.setData(total + f.size);For documents that were uploaded earlier (other tasks), read their sizes once when the coach loads - the BPM document store returns the size without CMIS:
GET /rest/bpm/wle/v1/process/{piid}?parts=documents -> data.documents[].size (bytes), name, mimeType
// or the Document List control's data: ${DocList}.getData().forEach(function (d) { total += d.size || d.contentSize || 0; });Server-side (service flow) the same information is tw.system.currentProcessInstance.documents (TWDocument.size) for the BPM document store, and tw.system.ecm / the ECM document properties (cmis:contentStreamLength) for FileNet - that one is a property fetch, not a search query.
References