![]() |
|
![]() ![]() ![]() |
Retrieving BLOB data
To retrieve BLOB data, the db query operation is executed. The variable contains a base64 encoded string, which you have to decode into a byte array.
Example
IVariable variable = mySession.getVariable("GetTestBlob");
IVariableField field = variable.getComplexVariable().getField("MyImage");
String projectPath = mySession.getAbsoluteProjectFilePath();
try {
FileOutputStream fos = new FileOutputStream(projectPath + "/ copytest.wav"); byte[] bytes = Base64.decode(field.getStringValue());
fos.write(bytes);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
Alternatively, you can also add .wav files to the database and retrieve it without having to write a Java code as follows:
You can also change the query behavior by coding using the setCreateTempFileForBlob(boolean flag, String fileType) method inside the dbop Java class.
Example
setCreateTempFileForBlob(false, null) - In this case, you will get back the bytes in Base64.
setCreateTempFileForBlob(boolean true, "gif") - In this case, the file created in the temp directory will have "gif" as the extension.
![]() ![]() ![]() |
©2009, Avaya Inc. All rights reserved.
|