Take Photo Action

Use this action in your application to take photos or choose images from the system's image library.

The action module for this action is "vb/action/builtin/takePhotoAction".

The behavior of this action depends on the type of application that you use it in:

  • Web application: Opens a File selection dialog to select a file
  • 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.

Clear the image input value from the Media Type dropdown 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.

Example 8-28 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, 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 }}"
                ]
    }
},