1 Reply Latest reply: Apr 6, 2013 11:29 PM by 991448 RSS

    Extracting a BLOB object from a db and writing it to a file

    kiransaravi
      Hi All

      Hope you are doing well.
      I have a requirement where I need to extract a blob object type from a db table and write it to a file.
      I've checked few blogs but nothing seems to answer my requirement. Would any of you suggest a method of doing it?

      Regards
      RaviKiran
        • 1. Re: Extracting a BLOB object from a db and writing it to a file
          991448
          The BLOB data would be received in binary format . You can use java embedding to decode this .Folloiwng is the java code for same.
          addAuditTrailEntry("Base64decode started");
          try {  
          XMLElement input = (XMLElement) getVariableData("inputVariable","payload","client:input");
          String input_str = input.getTextContent();
          addAuditTrailEntry("Base64decode input_str="+input_str);
          oracle.soa.common.util.Base64Decoder decoder = new oracle.soa.common.util.Base64Decoder();
          String decoded = null;
          decoded = decoder.decode(input_str);
          addAuditTrailEntry("Base64decode decoded="+decoded);
          setVariableData("outputVariable","payload","client:result",decoded);
          } catch (Exception e) {  
          addAuditTrailEntry("Base64decode Exception: "+e.getMessage());
          }
          addAuditTrailEntry("Base64decode ended");


          Alternatively you can also try to create the file adapter and specify native format and directly write the data. This should also work because the native format of the file format requries the input to be in base64encoding.

          Edited by: 988445 on Apr 6, 2013 9:29 PM