murp

Streams Binary Data Directly to the page

Mar 1st, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // this code streams binary data directly to the page.
  2. Blob/Data
  3. pic = test.largeImage[2];
  4. // Coming From File
  5. <cffile action="readbinary" file="C:\Inetpub\wwwroot\wireboxdemo\pictures\blog.png" variable="pic"/>
  6. <cfscript>
  7.     context = getPageContext();
  8.     context.setFlushOutput(false);
  9.     response = context.getResponse().getResponse();
  10.     out = response.getOutputStream();
  11.     response.setContentType("image/png");
  12.     response.setContentLength(arrayLen(pic));
  13.     out.write(pic);
  14.     out.flush();
  15.     out.close();
  16. </cfscript>
Add Comment
Please, Sign In to add comment