From 8b3aea532543fe426fd81ec6944e12c86f8ecc7b Mon Sep 17 00:00:00 2001 From: Yogendra Shelke Date: Sat, 21 Mar 2026 00:45:00 +0530 Subject: [PATCH] fix: add native payload to blob in TakePicture and TakePictureAdvanced functions --- .../mobile-resources-native/CHANGELOG.md | 4 ++++ .../src/camera/TakePicture.ts | 20 ++++++++++++++++++- .../src/camera/TakePictureAdvanced.ts | 18 ++++++++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/packages/jsActions/mobile-resources-native/CHANGELOG.md b/packages/jsActions/mobile-resources-native/CHANGELOG.md index 8fcf059db..2bec281b0 100644 --- a/packages/jsActions/mobile-resources-native/CHANGELOG.md +++ b/packages/jsActions/mobile-resources-native/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Fixed + +- We fixed an issue where the TakePicture and TakePictureAdvanced actions could fail to upload images by not passing the native file payload metadata required by the upload flow. + ## [11.3.7] Native Mobile Resources - 2026-3-14 ## [1.1.1] Switch diff --git a/packages/jsActions/mobile-resources-native/src/camera/TakePicture.ts b/packages/jsActions/mobile-resources-native/src/camera/TakePicture.ts index 324d6c15d..c7c806899 100644 --- a/packages/jsActions/mobile-resources-native/src/camera/TakePicture.ts +++ b/packages/jsActions/mobile-resources-native/src/camera/TakePicture.ts @@ -19,6 +19,17 @@ import { getLocales } from "react-native-localize"; import { ImagePickerV2Options, ImagePickerV2Response, PictureQuality, PictureSource } from "../../typings/Camera"; // BEGIN EXTRA CODE + +type NativePayload = { + uri: string; + name: string; + type: string; +}; + +type BlobWithNativePayload = Blob & { + nativePayload?: NativePayload; +}; + // END EXTRA CODE /** @@ -124,12 +135,19 @@ export async function TakePicture( // eslint-disable-next-line no-useless-escape const filename = /[^\/]*$/.exec(uri)![0]; const filePathWithoutFileScheme = uri.replace("file://", ""); + const blobWithNativePayload = blob as BlobWithNativePayload; + + blobWithNativePayload.nativePayload = { + uri, + name: filename, + type: blob.type + }; mx.data.saveDocument( imageObject.getGuid(), filename, {}, - blob, + blobWithNativePayload, async () => { await NativeModules.MendixNative.fsRemove(filePathWithoutFileScheme); diff --git a/packages/jsActions/mobile-resources-native/src/camera/TakePictureAdvanced.ts b/packages/jsActions/mobile-resources-native/src/camera/TakePictureAdvanced.ts index c141b842e..9b747db63 100644 --- a/packages/jsActions/mobile-resources-native/src/camera/TakePictureAdvanced.ts +++ b/packages/jsActions/mobile-resources-native/src/camera/TakePictureAdvanced.ts @@ -19,6 +19,15 @@ import { getLocales } from "react-native-localize"; import { ImagePickerV2Options, ImagePickerV2Response, PictureQuality, PictureSource } from "../../typings/Camera"; // BEGIN EXTRA CODE +type NativePayload = { + uri: string; + name: string; + type: string; +}; + +type BlobWithNativePayload = Blob & { + nativePayload?: NativePayload; +}; // END EXTRA CODE /** @@ -177,12 +186,19 @@ export async function TakePictureAdvanced( // eslint-disable-next-line no-useless-escape const filename = /[^\/]*$/.exec(uri)![0]; const filePathWithoutFileScheme = uri.replace("file://", ""); + const blobWithNativePayload = blob as BlobWithNativePayload; + + blobWithNativePayload.nativePayload = { + uri, + name: filename, + type: blob.type + }; mx.data.saveDocument( imageObject.getGuid(), filename, {}, - blob, + blobWithNativePayload, async () => { await NativeModules.MendixNative.fsRemove(filePathWithoutFileScheme);