How we can extract a attacment in a directory on server from blob.
Hi have a requirement in which i have to extacrt the attachment from blob and store the attachemnt in a directory in server.
Is there any way in pega to do that?
I have tried using tools.sendfile method but this method will show a pop uu to download the attachemnt and extact the docuemnt in service export directory.
***Updated by Moderator: Marissa. Removed user added #helpme and Ask the Expert group tags. Apologies for confusion, shouldn't have been an end-user option***

you can write an activity with java step and probably can use code similar to below
// queries the database
String sql = "SELECT * FROM pc_data_workattach WHERE pxattachname="+"\'"+FileName+"\'";
/*"+"\'"+"praxis2-1.6.2.jar"+"\'"+";"; */ /*"+"\'"+FileName+"\'";*/
oLog.debug(sql);
java.sql.PreparedStatement statement = conn.prepareStatement(sql);
//statement.setInt(1, FileName);
java.sql.ResultSet result = statement.executeQuery();
if (result.next()) {
String fileName = result.getString("pxattachname");
java.sql.Blob blob = result.getBlob("pzpvstream");
java.io.InputStream inputStream = blob.getBinaryStream();
int fileLength = inputStream.available();
//ParseState parseState = (ParseState) tools.getStepPage().getObject("pyParseState");
//java.io.InputStream is = parseState.getInputStream();
byte[] buffer = new byte[inputStream.available()];
inputStream.read(buffer);
java.io.File targetFile = new java.io.File(FileLocation+"\\"+fileName);
java.io.OutputStream outStream = new java.io.FileOutputStream(targetFile);
outStream.write(buffer);
inputStream.close();
outStream.close();