* @param response
*/
public static void outStream(String bouid, String thisuuid, String name,
String rename, String downLoadSizeCol, HttpServletResponse response) {
DOBO bo = DOBO.getDOBOByID(bouid);
BOInstance instance = bo.getInstance(thisuuid);
String renameValue = "attachment";
if (rename != null) {
renameValue = instance.getValue(rename);
try {
renameValue = URLEncoder.encode(renameValue, "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
response.addHeader("Content-Disposition", "attachment;filename="
+ renameValue);
StringBuffer sql = new StringBuffer("select ");
sql.append(name);
sql.append(" from ").append(bo.getSqlStr()).append(" where ").append(
bo.getKeyCol()).append(" = ?");
log.info("The get blob sql is " + sql);
Connection con = null;
OutputStream output = null;
InputStream is = null;
try {
con = bo.getDataBase().getContextConnection();
PreparedStatement pstmt = con.prepareStatement(sql.toString());
pstmt.setString(1, thisuuid);
ResultSet rset = pstmt.executeQuery();
Blob blob = null;
if (rset.next()) {
blob = (Blob) rset.getBlob(1);
}
output = response.getOutputStream();
is = blob.getBinaryStream();
byte[] b = new byte[1024];
int i = 0;
while ((i = is.read(b)) > 0) {
output.write(b, 0, i);
}
output.flush();
} catch (Exception ex1) {
log.error(ex1);
} finally {
try {
bo.getDataBase().ifCloseConnection(con);
if (is != null) {
is.close();
is = null;
}
if (output != null) {