CFCONTENT was being used previously, but when a bunch of users start 
downloading large files, the server starts crashing...
Most of the files range between 200-500 MB, some up to 1GB and larger...




----- Original Message ----- 
From: "Craigsell" <[EMAIL PROTECTED]>
To: "CF-Talk" <[email protected]>
Sent: Monday, January 21, 2008 4:32 PM
Subject: Re: Read large binary file, MX7?


> Dave is right --- when in CF use CF!
>
> Here's a code snippet fron June 19,2003 entry is Chris Cantrell's blog 
> (he's
> an Adobe expert)
> http://weblogs.macromedia.com/cantrell/archives/coldfusion/index.cfm
>
>
> <cffile action="readbinary" file="/home/cantrell/Pictures/Corrs2.jpg"
> variable="pic"/>
> <cfcontent type="image/gif; charset=8859_1">
> <CFSCRIPT>
>    writeOutput(toString(pic));
> </cfscript>
>
> Just change the content type to what you need!
>
>
> ----- Original Message ----- 
> From: "Sarah Geren" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[email protected]>
> Sent: Monday, January 21, 2008 2:38 PM
> Subject: Re: Read large binary file, MX7?
>
>
>> thanks,
>> I was actually originally trying to use this piece of code that I found
>> using java to read through the object, but I am so not a Java person and
>> got
>> stuck when I needed to add the following parameter:
>> response.setContentLength(arrayLen(byte_arry_here));
>> into the script so that the browser knows how much it is downloading...
>> I tried:
>>    response.setContentLength(arrayLen(instream));
>>    response.setContentLength(arrayLen(byteArray));
>>    response.setContentLength(arrayLen(s_file));
>> but none worked... So I gave up and decided to use cfffile, until
>> realizing
>> how large some of the files were. I just wasn't sure if there was
>> something
>> else I could do with cffile that would make my original code work...
>>
>> So can someone tell me instead how to call the content length into the
>> script below please?
>>
>> <cfscript>
>> function f_Stream(s_file,i_seek,MIME_TYPE,fileName) {
>>  var i_position = i_seek;
>>  var i_buffer = 10000;
>>  var byteClass = createObject("java", "java.lang.Byte"); //
>>  var byteArray =
>> createObject("java","java.lang.reflect.Array").newInstance(byteClass.TYPE,
>> i_buffer);
>>  var context = getPageContext();
>>  var response = context.getResponse().getResponse();
>>
>>  var instream = createObject("java", "java.io.FileInputStream");
>>  var outstream = response.getOutputStream(); // take over control of the
>> feed to the browser
>>  if(structKeyexists(arguments,"MIME_TYPE"))
>>   response.setContentType(MIME_TYPE);
>>  if(structKeyExists(arguments,"fileName"))
>>   response.setHeader("content-disposition","attachment;
>> filename=#fileName#");
>>  byteClass.Init(1);
>>  instream.init(s_file);
>>  context.setFlushOutput(false);
>>  try {
>>   if(i_seek GT 0) {
>>    //instream.skip(i_seek);
>>    //outstream.write(toBinary('RkxWAQEAAAAJAAAACQ==')); // output the
>> header bytes
>>   }
>>   do {
>>    i_length = instream.read(byteArray,0,i_buffer);
>>    if (i_length neq -1) {
>>     outstream.write(byteArray);
>>     outstream.flush();
>>    }
>>   } while (i_length neq -1); // keep going until there's nothing left to
>> read.
>>  }
>>  catch(any excpt) {}
>>  outstream.flush(); // send any remaining bytes
>>  response.reset(); // reset the feed to the browser
>>  outstream.close(); // close the stream to flash
>>  instream.close(); // close the file stream
>> }
>> </cfscript>
>> <cfset
>> f_Stream("#scene_data.mpeg#",0,"video/mpeg","scene_#scene_id#.mpg")>
>>
>>
>>
>> ----- Original Message ----- 
>> From: "Sonny Savage" <[EMAIL PROTECTED]>
>> To: "CF-Talk" <[email protected]>
>> Sent: Monday, January 21, 2008 3:07 PM
>> Subject: Re: Read large binary file, MX7?
>>
>>
>>> Any time I find a bottleneck with CF tags, I generally go looking for a
>>> Java
>>> solution.  These pages may have useful snippets...
>>> http://www.coldfusionmuse.com/index.cfm/2006/10/26/Java.directory.list
>>> http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html
>>> http://www.scripts.com/coldfusion-scripts/file-manipulation-scripts/
>>>
>>> On Jan 21, 2008 2:27 PM, Sarah Geren <[EMAIL PROTECTED]> wrote:
>>>
>>>> Hello,
>>>>
>>>> I have an application which uses CFFILE to read a binary file into a
>>>> variable, and that variable is used to write out the video to the 
>>>> brower
>>>> so
>>>> someone can download it...
>>>> This code is working great, until the file sizes become too large. It
>>>> seems to stop working (and returns a null null or 500 null error) when
>>>> the
>>>> file sizes go past 200-250MB...
>>>> There are some files on this server that are up to 1GB in size that 
>>>> have
>>>> to be downloaded via this script, so it needs to be able to handle
>>>> pretty
>>>> big files.
>>>>
>>>> The server is MX7, 4GB Ram, and here are my java args:
>>>>
>>>> java.args=-server  -DJINTEGRA_NATIVE_MODE -DJINTEGRA_PREFETCH_ENUMS
>>>> -Xms1024m -Xmx1024m -Dsun.io.useCanonCaches=false -XX:MaxPermSize=512m
>>>> -XX:PermSize=64m -Dcoldfusion.rootDir={application.home}/../ -
>>>> Dcoldfusion.libPath={application.home}/../lib -XX:+UseConcMarkSweepGC
>>>> -XX:+UseParNewGC
>>>> -XX:NewSize=48m  -Dcoldfusion.classPath={application.home}/../lib/updates
>>>> ,{application.home}/../lib,{application.home}/../gateway/lib/,{
>>>> application.home}/../wwwroot/WEB-INF/cfform/jars
>>>>
>>>> Any help would be appreciated!
>>>> Thanks!
>>>>
>>>> <cffile action="readbinary" file="#scene_data.mpeg#" variable="video">
>>>> <cfheader name="Content-disposition" value="attachment;
>>>> filename=scene_#scene_id#.mpg">
>>>> <cfscript>
>>>>    context = getPageContext();
>>>>    context.setFlushOutput(false);
>>>>    response = context.getResponse().getResponse();
>>>>    out = response.getOutputStream();
>>>>    response.setContentType("video/mpeg");
>>>>    response.setContentLength(arrayLen(video));
>>>>    out.write(video);
>>>>    out.flush();
>>>> response.reset();
>>>> out.close();
>>>> </cfscript>
>>>>
>>>>
>>>
>>>
>>
>>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:297035
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to