Thursday

Convert an image to Base64

This post is to show how to generate base64 string to an image file.

Below is the method which will return the base64 string to the given image file.
The input for this method is the full path of the image.

    public String getBase64ForFile(String inFile) throws Exception {
        String base64 = "";
        System.out.println("inFile: " + inFile);
        URL url = new URL(inFile);
        InputStream fin = url.openStream();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        int next = 0;
        while ((next = fin.read()) != -1) {
            bos.write(next);
        }
        bos.flush();
        base64 = "" + org.kobjects.base64.Base64.encode(bos.toByteArray());
        System.out.println("Base64: " + base64);

        bos.close();
        fin.close();
        return base64;
    }

Wednesday

ERROR: Plugin 'Camera' not found, or is not a CDVPlugin. Check your plugin mapping in Cordova.plist

I am developing a MAF application in which I need to collect images from the user for which I provided a button. On click of the button, photo library supposed to be opened, so that the user can select the images. But on click of the button, I am getting the below error.

Error:
Plugin 'Camera' not found, or is not a CDVPlugin. Check your plugin mapping in Cordova.plist.

This is because the app is not granted access to required device capabilities.
To give the access, go to maf-application.xml and click on "Device Access", then grant access to required capabilities.

Below is the example where I granted for Camera and Files to avoid the above error.


Sunday

How to enable Contribution Folders in Webcenter Content

If the “Contribution Folders” under Browse Content is not visible, please follow the below procedure to enable it.
  • Login to webcenter content
  • Under Administration menu, go to Admin Server and select “Component Manager” option
  • Select “advanced component manager” option

  • Under disabled components, select “Folders_g” and click on enable button
  • Please note that, while enabling “Folders_g”, if “FrameworkFolders” is enabled, then disable it, because both the options should not be enabled. Either of those should be enabled at a time
                                         
  • Now, you will see an alert message to restart the server
  • Restart the content server
  • After restart, if you login to webcenter content and go to “Browse Content”, you can see the “Contribution Folders”