Skip to main content
September 28, 2010
Answered

CFContent failing on large files since moving to ColdFusion 9

  • September 28, 2010
  • 5 replies
  • 4189 views

Keep getting "The website canno display the page". It is ok when the file is 50MB, but when 300MB or above  - it failed.

It worked on CF8. We migrated to CF9 during the weekend and all the settings are the same.

I found that several CF users ran into similar issue - so I know it's not only me like Dan, Tom, etc (http://www.mail-archive.com/cf-talk@houseoffusion.com/msg348532.html)

Thanks,

Pat.

This topic has been closed for replies.
Correct answer hemant_k1

We are currently investigating this bug.

5 replies

February 21, 2011

http://www.bennadel.com/blog/1227-Using-ColdFusion-To-Stream-Files-To-The-Client-Without-Loading-The-Entire-File-Into-Memory.htm

Better solution than working on memory issues. Check this link for Ben's solution.

February 11, 2011

To fix this:

  1. Login to the administrator panel for Coldfusion 9.x
  2. Choose Java and JVM
  3. Set the " " to 1024 or appropriate value. Old value was 512 MB and seems to not be enough.
  4. Restart Coldfusion services.

Seems to be an with memory needed for Java and I was able to download large files afterwards on my 64-bit OS with CF 9.01.

Enjoy.

Jon Almada

Participating Frequently
February 4, 2011

This has caused me a bit of a nightmare. When you upgrade versions, you expect things to at least improve. This has to be a priority fix - it's a howling problem!

Anyhow, for the benefit of others in a similar situation, I eventually got around this by creating a read-only FTP account (literally read-only - the user can't even list files/directories) on our web server and then I use a cflocation redirect instead of the cfcontent approach to serve up the file. I use UUIDs as folder names, so it's a pretty safe way of stopping people from downloading content they shouldn't.

So, instead of this...

<cfset Path = "#pathToMyFile#\#myFileName#">

<cfset FileInfo = GetFileInfo(Path)>
<cfset FileSize = FileInfo.size>
<cfset MimeType = getPageContext().getServletContext().getMimeType(Path)> <!--- Sometimes doesn't work, so we need to check that MimeType exists below --->

<cfheader name="Content-Disposition" value="attachment; filename=""#myFileName#""">

<cfheader name="Expires" value="#Now()#">
<cfheader name="Content-Length" value="#FileInfo.size#">
<cfif IsDefined("MimeType")>
     <cfcontent type="#MimeType#" file="#Path#" deletefile="No">
<cfelse>
     <cfcontent type="application/octet-stream" file="#Path#" deletefile="No">
</cfif>

I now have this...


<cfset FTPDownloadLink = "ftp://myAnonymousUser@ftp.mydomain.com/myFTPPath/#myFileName#">
<cflocation url="#FTPDownloadLink#" addtoken="no">

I suspect that this is actually a better way of doing things anyway, since it offloads responsibility to serving the file from the CF server to the FTP, which is, after all, what it is designed to do.

hemant_k1Correct answer
Participating Frequently
October 7, 2010

We are currently investigating this bug.

Inspiring
September 28, 2010

Firstly, I think you should o vote for the bug that's been raised to cover this:

http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=83425


I've not played with this at all, but it looks to me like this is similar to a thing older versions of CF used to have when serving up files with <cfcontent>: the whole file gets loaded into RAM, and only then spooled back to the browser.

I wonder if it would be possible to just used <cfcontent> to set the MIME type, and then used <cfflush interval="somethingSensible">, fileRead() or fileReadBinary() and <cfoutput> to read&spool the file at the same time?  This might also be quicker given the data is being spooled at the same time as it's being read, rather than being done in series.

That said... this is entirely speculation on my part... amn't in the position to test this approach at the mo', sorry.

--

Adam

September 30, 2010

Thank you, Adam.  For now - we decided to downgrade back to CF8. Everything is working ok now.

I will look into your suggest/method within the next few weeks and post the results/findings since we still have CF9 on our Dev environment and it's making the same fuss with larger files.

CF9 have some good / awesome tags for map and media - it's a bum that me/team will not be able to show this awesomeness to the users sooner

Thanks again,

Pat.

Inspiring
September 30, 2010

I will look into your suggest/method within the next few weeks and post the results/findings since we still have CF9 on our Dev environment and it's making the same fuss with larger files.

Cool.  I'd be keen to hear how you go.  If I find any time, I'll have a look @ it myself, but I am very bogged down with work @ the mo'.

--

Adam