Document endpoints of a property and the main image
The document list, upload checks and storage path, detaching, linking an existing document with role rules, and setting the main image.
Property documents are linked through the document centre relation (doc_link, object_type = property); storage goes through the document centre's central path. Every document action requires content scope for the document's company.
List
docs (list permission, GET property_id): document/document::getDocsForObject('property', id), only documents of companies within the user's content scope. A document with a role from Dlbtproperty::DOC_ROLES goes to its slot, other images to the gallery, other non-images to "Other documents". The main image (cover_doc_id) comes first. Each item has an open URL (document/document.preview), images have thumbnail URLs (480, 960, 2048 px), and with edit a detach URL.
Upload
docupload(edit; POSTproperty_id,doc_role,file), one request per file, sent sequentially by the client.- Checks: unsaved property; unknown role (
DOC_ROLES+photo+attachment); empty POST (post_max_size); failed file; neither owner nor operator; document owner company outside scope; forphotoa non-image (jpg, jpeg, png, gif, webp). - Storage:
Dlbtdocstore::addDocument()(file name normalised to ASCII,company_id= owner, otherwise operator,object_type = property,doc_role); read back withgetDoc(); success: "Document uploaded.".
Document roles: safety_report, energy_certificate, land_registry, floor_plan, attachment, plus photo.
Detaching and linking
docunlink(edit): only for an existing document linked to the property whose company is in scope;deleteDocLink(), the document remains.- Linking an existing document (
edit, for several documentsbulkedit): search throughdocument/folders.docsearch&ctx=property(at least 2 characters), link throughdocument/document.addlink&ctx=propertywith the slot's role. Role rule:photoonly for images (other files asattachment), and only a document with an empty, general or property role is re-classified. - The Documents list header has an "Assign to property" bulk button: it requires the labelling permission and the property
listpermission.
Main image
cover (edit; GET property_id, doc_id; doc_id = 0 clears): only an image linked to the property and within scope. Without migration 20261031_008 a descriptive error; on read-back mismatch "The main image was not saved (read-back mismatch).". With cover_doc_id = 0 the first gallery image is the cover. The gallery shows 12 images by default; an image opens in the shared viewer (pdf.js for PDF if installed).
Data room
The data room shows the main image, the gallery and — only within the user's shared folder — the documents (getPropertyForView(): active property assigned to the current store).