Hibernate reads pictures from Oracle database

Part of the code is as follows:

        Blob blob=reward.getAttachment();


OutputStream out = response.getOutputStream();
if(blob==null){
return;
}else{
               InputStream inputStream = blob.getBinaryStream();
               response.setContentType("image/jpeg;charset=UTF-8");
         response.setCharacterEncoding("UTF-8"); int num; byte buf[] = new byte[1024]; while(   (num=inputStream.read(buf))!=-1   ){ out.write(buf, 0, num); } out.flush(); out.close();

        
        
        

         
        
        

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324520765&siteId=291194637