convert System.Image into blob

0
How to convert System.Image into blob in mendix native application.  Functionality is, to convert the picture taken from mobile device and pass the picture has blob content to js action to other third party api. Since we  have a constraint that, not able pass the System.Image object from nanoflow to microlfow in mendix native app. So decided to convert the image into blob and pass it to required js action to perform the functionality.   Thanks!! 
asked
1 answers
3

Check out NativeMobileActions.SaveToPictureLibrary. This JS action has code that gets you a URL to the file/image blob. From there you can fetch the blob or pass it wherever it’s needed.

Code also here below:

if (!picture) {
    return Promise.reject(new Error("Input parameter 'Picture' is required"));
}
if (!picture.inheritsFrom("System.FileDocument")) {
    const entity = picture.getEntity();
    return Promise.reject(new Error(`Entity ${entity} does not inherit from 'System.FileDocument'`));
}
const guid = picture.getGuid();
const changedDate = picture.get("changedDate");
const url = mx.data.getDocumentUrl(guid, changedDate);
return CameraRoll.saveToCameraRoll(url);

 

answered