Skip to content

Commit bcfd769

Browse files
fix: add native payload to blob in TakePicture and TakePictureAdvanced functions
1 parent ecab899 commit bcfd769

3 files changed

Lines changed: 42 additions & 4 deletions

File tree

packages/jsActions/mobile-resources-native/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- 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.
12+
913
## [11.4.1] Native Mobile Resources - 2026-3-14
1014

1115
## [2.0.2] GalleryTextFilter

packages/jsActions/mobile-resources-native/src/camera/TakePicture.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ import { getLocales } from "react-native-localize";
1919
import { ImagePickerV2Options, ImagePickerV2Response, PictureQuality, PictureSource } from "../../typings/Camera";
2020

2121
// BEGIN EXTRA CODE
22+
23+
type NativePayload = {
24+
uri: string;
25+
name: string;
26+
type: string;
27+
};
28+
29+
type BlobWithNativePayload = Blob & {
30+
nativePayload?: NativePayload;
31+
};
32+
2233
// END EXTRA CODE
2334

2435
/**
@@ -124,12 +135,19 @@ export async function TakePicture(
124135
// eslint-disable-next-line no-useless-escape
125136
const filename = /[^\/]*$/.exec(uri)![0];
126137
const filePathWithoutFileScheme = uri.replace("file://", "");
138+
const blobWithNativePayload = blob as BlobWithNativePayload;
139+
140+
blobWithNativePayload.nativePayload = {
141+
uri,
142+
name: filename,
143+
type: blob.type
144+
};
127145

128146
mx.data.saveDocument(
129147
imageObject.getGuid(),
130148
filename,
131149
{},
132-
blob,
150+
blobWithNativePayload,
133151
async () => {
134152
await NativeModules.MendixNative.fsRemove(filePathWithoutFileScheme);
135153

@@ -322,7 +340,7 @@ export async function TakePicture(
322340
);
323341
}
324342

325-
function handleImagePickerV4Error(errorCode: ErrorCode, errorMessage?: string) {
343+
function handleImagePickerV4Error(errorCode: ErrorCode, errorMessage?: string): void {
326344
switch (errorCode) {
327345
case "camera_unavailable":
328346
showAlert("The camera is unavailable", "");

packages/jsActions/mobile-resources-native/src/camera/TakePictureAdvanced.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ import { getLocales } from "react-native-localize";
1919
import { ImagePickerV2Options, ImagePickerV2Response, PictureQuality, PictureSource } from "../../typings/Camera";
2020

2121
// BEGIN EXTRA CODE
22+
type NativePayload = {
23+
uri: string;
24+
name: string;
25+
type: string;
26+
};
27+
28+
type BlobWithNativePayload = Blob & {
29+
nativePayload?: NativePayload;
30+
};
2231
// END EXTRA CODE
2332

2433
/**
@@ -177,12 +186,19 @@ export async function TakePictureAdvanced(
177186
// eslint-disable-next-line no-useless-escape
178187
const filename = /[^\/]*$/.exec(uri)![0];
179188
const filePathWithoutFileScheme = uri.replace("file://", "");
189+
const blobWithNativePayload = blob as BlobWithNativePayload;
190+
191+
blobWithNativePayload.nativePayload = {
192+
uri,
193+
name: filename,
194+
type: blob.type
195+
};
180196

181197
mx.data.saveDocument(
182198
imageObject.getGuid(),
183199
filename,
184200
{},
185-
blob,
201+
blobWithNativePayload,
186202
async () => {
187203
await NativeModules.MendixNative.fsRemove(filePathWithoutFileScheme);
188204

@@ -385,7 +401,7 @@ export async function TakePictureAdvanced(
385401
});
386402
}
387403

388-
function handleImagePickerV4Error(errorCode: ErrorCode, errorMessage?: string) {
404+
function handleImagePickerV4Error(errorCode: ErrorCode, errorMessage?: string): void {
389405
switch (errorCode) {
390406
case "camera_unavailable":
391407
showAlert("The camera is unavailable.", "");

0 commit comments

Comments
 (0)