From 37948e1f6d8b73cf9039fbc1ecd479ccfb3c28f2 Mon Sep 17 00:00:00 2001 From: "Leon.Schmidt" Date: Fri, 21 Aug 2026 00:35:18 +0200 Subject: [PATCH] FIX - bind FiveManage uploads by storage key --- frontend/src/mediaConfig.server.contract.test.ts | 3 ++- sky_phone/source/server/media.lua | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/src/mediaConfig.server.contract.test.ts b/frontend/src/mediaConfig.server.contract.test.ts index 8929737..6457255 100644 --- a/frontend/src/mediaConfig.server.contract.test.ts +++ b/frontend/src/mediaConfig.server.contract.test.ts @@ -92,7 +92,8 @@ describe('FiveManage server configuration contract', () => { expect(mediaServer).toContain( 'path:find("/" .. state.upload_path .. "/", 1, true)', ) - expect(mediaServer).toContain('object_id ~= remote_id') + expect(mediaServer).toContain('local storage_key = path:sub(2)') + expect(mediaServer).toContain('}, nil, storage_key') expect(mediaServer).toContain('"HEAD"') expect(mediaServer).toContain( 'SkyPhoneMediaImport.ResponseHeader(response.headers, "content-type")', diff --git a/sky_phone/source/server/media.lua b/sky_phone/source/server/media.lua index c360248..464eeda 100644 --- a/sky_phone/source/server/media.lua +++ b/sky_phone/source/server/media.lua @@ -203,10 +203,11 @@ local function probe_uploaded_object(state, remote_id, uploaded_url) Bridge.Debug("error", "[sky_phone][media-debug] FiveManage upload URL is not bound to the server upload path.") return nil, "invalid_upload_token" end - local filename = path:match("/([^/]+)$") - local object_id = filename and filename:match("^([%w_%-]+)%.[%w]+$") or nil - if object_id ~= remote_id then - Bridge.Debug("error", "[sky_phone][media-debug] FiveManage upload URL does not contain the returned file ID.") + local storage_key = path:sub(2) + if #storage_key > 128 or storage_key:find("//", 1, true) + or not storage_key:match("^[%w%._%-%/]+$") + then + Bridge.Debug("error", "[sky_phone][media-debug] FiveManage upload URL contains an invalid storage key.") return nil, "invalid_upload" end @@ -255,7 +256,7 @@ local function probe_uploaded_object(state, remote_id, uploaded_url) size = size, type = mime_type, url = uploaded_url, - }, nil, remote_id + }, nil, storage_key end local function get_remote_file(state, remote_id, uploaded_url)