BPM, Workflow, and Case

BPM, Workflow, and Case

Come for answers. Stay for best practices. All we’re missing is you.

 View Only
  • 1.  How to Save Documents to External Database

    Posted Tue August 01, 2023 06:54 PM

    Can we store and retrieve the documents from IBM BAW with out of the box ECM Content Toolkit.

    Our use case is to store the document in oracle DB as BLOB . I guess we can use content integration control to get the content stream as base64. But how to display or allow user to retrieve the file?

    Thank you!



    ------------------------------
    Harish Puli
    ------------------------------


  • 2.  RE: How to Save Documents to External Database

    Posted Wed August 02, 2023 12:37 AM

    Hi Harish,

    There are different ways of displaying the base64 string as a file in browser, like - 

    1. You can try using <object> tag and pass the base64 string along with the mime type. This would fine for images, text, html, pdf etc. but probably won't work for word, excel, ppt etc. 
      <object data="<YOUR_BASE64>" type="application/pdf" style="width: 100%; height: 100%"></object>
    2. You can use some 3rd party library like - PSPDFKit

    Thanks!



    ------------------------------
    Atanu Roy
    Solution Architect
    Salient Process
    ------------------------------



  • 3.  RE: How to Save Documents to External Database

    Posted Wed August 02, 2023 02:24 AM

    Hi Harish,

    Yes you can. Using below steps you can able to retrieve the content and update in your DB.

    1. While uploading any document using BPM File upload control, you can fetch the document id calling a custom function on file upload passing file as an argument.
    2. Fetch the document id using file.xhr.responseXml.childNodes[0].textContent
    3. pass the docId to OOTB ECM method GetDocumentContent
    4. Fetch the contentstream as base64 and upload it to Oracle DB
    5. On Click of the URL you can retrieve the blob element and construct an URL to download the document to user's system. 

     this is a sample code. 

    function convertDataURIToBinary(fileName, bytes, type) {
        //Chrome specific code
        var byteCharacters = atob(bytes);
        var blob;
        var byteNumbers = new Array(byteCharacters.length);
        for (var i = 0; i < byteCharacters.length; i++) {
            byteNumbers[i] = byteCharacters.charCodeAt(i);
        }
        var byteArray = new Uint8Array(byteNumbers);
        var link = document.createElement("a");
        link.setAttribute("target", "_blank");
        if (Blob !== undefined) {
            console.log("if condition");
            if (type == "image/jpeg" || type == "image/jpg") {
                blob = new Blob([byteArray], {
                    type: "image/jpeg"
                });
            } else {
                blob = new Blob([byteArray], {
                    type: type
                });
            }
        } else {
            link.setAttribute("href", type + encodeURIComponent(bytes));
        }
        var url = URL.createObjectURL(blob);
        var pdfWindow = window.open("");
        pdfWindow.document.write("<iframe width='100%' height='100%' src='" + url + "'></iframe>");
    }



    ------------------------------
    Rameshkumar C
    ------------------------------



  • 4.  RE: How to Save Documents to External Database

    Posted Wed August 02, 2023 09:20 AM

    Hey Harish,

    There's 2 content toolkits. The old one is designed to work with any CMIS-compliant document repository. The newer one is designed specifically to consume the FileNet Content Manager GraphQL API. For light-weight workloads, the embedded content store would be the preferred approach and, as long as BAW is using an Oracle database, can be configured to store the content in a "Database Storage Area" which will store the docs in the underlying db as a blob. That said, using blob storage for documents at any sort of scale is a performance nightmare and is not advisable for average file sizes larger than 100 KB (i.e. some simple XML or JSON, plain text sort of documents). Using the embedded document store or an external FileNet instance the way the platform is designed will mean the viewer, etc. that are part of the toolkit should just work, and you'd be able to use the more modern toolkit.

    Best,

    Eric



    ------------------------------
    Eric Walk
    Director

    O: 617-453-9983 | NASDAQ: PRFT | Perficient.com
    ------------------------------