Skip to content
This repository was archived by the owner on Dec 21, 2022. It is now read-only.

Commit 6fde738

Browse files
Merge pull request #222 from mendix/fix/take-picture-security-issue
[WT-2521] TakePicture JavaScript action stores picture in temporary folder
2 parents 381ca1e + 8829dac commit 6fde738

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages-native/actions/src/camera/TakePicture.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// - the code between BEGIN USER CODE and END USER CODE
55
// Other code you write will be lost the next time you deploy the project.
66

7-
import { Alert, Linking } from "react-native";
7+
import { Alert, Linking, NativeModules } from "react-native";
88
import ImagePicker from "react-native-image-picker";
99

1010
type PictureSource = "camera" | "imageLibrary" | "either";
@@ -89,8 +89,11 @@ export async function TakePicture(
8989
const guid = imageObject.getGuid();
9090
// eslint-disable-next-line no-useless-escape
9191
const filename = /[^\/]*$/.exec(uri)![0];
92-
const onSuccess = (): void => resolve(true);
93-
const onError = (error: Error): void => reject(error);
92+
const onSuccess = (): void => NativeModules.NativeFsModule.remove(uri).then(() => resolve(true));
93+
const onError = (error: Error): void => {
94+
NativeModules.NativeFsModule.remove(uri).then(undefined);
95+
reject(error);
96+
};
9497

9598
mx.data.saveDocument(guid, filename, {}, blob, onSuccess, onError);
9699
});
@@ -126,6 +129,11 @@ export async function TakePicture(
126129
text: "To enable access, tap Settings > Permissions and turn on Camera and Storage.",
127130
reTryTitle: "Settings",
128131
okTitle: "Cancel"
132+
},
133+
storageOptions: {
134+
skipBackup: true,
135+
cameraRoll: false,
136+
privateDirectory: true
129137
}
130138
};
131139
}

0 commit comments

Comments
 (0)