Server helpers walk or create a folder path (for example a year and month under a named root), then upload a buffer into that folder. Folder ids are cached per account and parent so repeated uploads do not re-list. When the upload response omits a URL, the file metadata is fetched by id to obtain it.
Also called: upload photos to CRM · media folders · job photo storage
- 1Caller resolves a media context (token, location, org).
- 2ensureGhlFolderPath walks the path, creating any missing folder.
- 3uploadBufferToGhl posts the file with the folder as parentId.
- 4If no URL comes back, the file id is used to read the metadata.
- 5The returned CDN URL is checked for tenant ownership before being used.
The file records a vendor quirk and a correction. The quirk: 'GHL quirk that still holds: parentId (not folderId) both when creating folders and uploading.' The correction is dated and blunt: 'CORRECTED 08-22: this file used to say "JPEG/PNG not WebP". That was tested against the live API and is FALSE — a WebP upload returns HTTP 201 with a .webp filesafe CDN URL, exactly like JPEG. New image work goes through src/lib/imagePipeline.ts, which emits WebP on purpose (25-35% smaller at equal quality). Do not reintroduce a JPEG-only rule here.'
- Uploaded images had no consistent filing structure.
- A false format rule was forcing larger files than necessary.
See it on your own jobs
Twenty minutes, your numbers, no slide deck. We’ll build one of your real buildings in front of you and send you the estimate link at the end — yours to keep either way.
or keep browsing features →