Take Photo Action

The action module for this action is vb/action/builtin/takePhotoAction. Use this action in a mobile application to take photos or choose images from the system's image library. The takePhotoAction is deprecated for web applications. Use the JET file upload component, or the camera component in the Components palette which uses the JET file upload component.

The behavior of this action depends on the type of application that you use it in:
  • iOS application: Prompts user with multiple options, such as Camera, Browse, or Like
  • Android application: Prompts user with options, such as Camera, Browse, or Cancel
  • Progressive web apps on Android and iOS: Prompts user with multiple options, such as Camera, Browse, or Like
Parameter Name Description
mediaType

Set to image by default. The video type is also supported.

Clear the image input value from the Media Type drop-down list if you want your mobile application to use the deprecated Take Photo action implementation from pre-19.1.3 releases. The pre-19.1.3 Take Photo action can only be used in Android and iOS applications.

If mediaType is set to video:
  • For iOS Native apps, options to record video using the Camera or to select video files will be provided.
  • For Android Native apps, only file selection is allowed. Recording using the Camera is not supported.
  • For PWA apps on iOS and Android, options to record video using the Camera or to select video files will be provided.

Example 1-46 Example

The outcome of this action is a binary data object (blob) duck-typed as File. The outcome name is file.

// To use the outcome file in images, use the URL.createObjectURL and URL.revokeObjectURL 
// methods, as in the following example
const blobURL = URL.createObjectURL(fileBlob);

// Release the BLOB after it loads.
document.getElementById("img-712450837-1").onload = function () {
    URL.revokeObjectURL(blobURL);
};

// Set the image source to the BLOB URL
document.getElementById("img-712450837-1").src = blobURL;


// To upload the selected/captured image or video, use restAction and set the body of 
// restAction to the outcome file of takePhotoAction.
"takePhoto1": {
    "module": "vb/action/builtin/takePhotoAction",
    "parameters": {
        "mediaType": "image"
    },
    "outcomes": {
        "success": "callTakePhotoSuccess",
        "failure": "callTakePhotoFailed"
    }
},
"callRestEndpoint1": {
    "module": "vb/action/builtin/restAction",
    "parameters": {
        "endpoint": "OracleCom/postUpload",
        "body": "{{ $chain.results.takePhoto1.file }}", // <- File is set as body of restAction
        "contentType": "image/jpeg"
    },
    "outcomes": {
        "success": "callUploadSuccess",
        "failure": "callUploadFailed"
    }
},
"callUploadFailed": {
    "module": "vb/action/builtin/callModuleFunctionAction",
    "parameters": {
        "module": "{{$page.functions}}",
        "functionName": "uploadFailed",
        "params": [
            "{{ $chain.results.callRestEndpoint1.body }}"
        ]
    }
},
"callUploadSuccess": {
    "module": "vb/action/builtin/callModuleFunctionAction",
    "parameters": {
        "module": "{{$page.functions}}",
        "functionName": "uploadSuccess",
        "params": [
            "{{ $chain.results.callRestEndpoint1.body }}"
        ]
    }
},