Convert BLOB to file

I’m reading a BLOB from a db column and it ends up in the results output of the query method. The BLOB is contained in a T/String wm type. It appears to be base64 encoded but I’m not sure …

Has anyone successfully taking that String and actually written it to a filesystem in its native format so it can be viewed?

Here is what I tried:

  1. Took the string and pub.string:base64decoded it into a byte type.
  2. Sent it to a Java service that executed the following code:

IDataHashCursor pipelineCursor = pipeline.getHashCursor();

pipelineCursor.first( “pathToFile” );
String pathToFile = (String) pipelineCursor.getValue();

pipelineCursor.first( “bytes” );
Object bytes = pipelineCursor.getValue();

ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
byte theObjectBytes = baos.toByteArray();
File f = new File(pathToFile);
FileOutputStream fos = new FileOutputStream(f);
}catch (Exception e){

but unfortunantly it was mangled. Any thoughts on whats going on?

It may be worthwile inserting a text string as BLOB data in your DB. Then try reading the BLOB and running the output of base64decode to pub.string:bytesToString to see if its what you expected.

> appears to be base64 encoded but I’m not sure …

I think base64 data encoded by WM ends with a “==”.

Hope that helps!

Right on, thanks for the tip. I’ll try that out.

Mike, are you using webMethods IS to insert the BLOB into the database, too? We had some issues getting that done and were told by webMethods that BLOB data can be read but not written.

Hmm, at some point we will be inserting BLOBs, but at this point its only reading…

I too have heard from WM that its not trivial to write BLOBs and heard something along the lines of having to write JDBC calls directly in a Java flow script.