ColdFusion CDN Download
I am building a simple API that downloads files off a thirdparty CDN (Cloud Files). ColdFusion is currently successfully getting this file and by using CfContent and cfhead开发者_开发问答er the file is available for download and the person who called the API.
The problem I am having is that these files are secure files so i cannot use a direct link to the CDN, and these files can range from 50MB-5GB. So because of these two issues, when I get the file from the CDN using CfHTTP, and then do this
<cfcontent type="MMIETYPE" variable="#CFHTTP.FileContent#" >
Im confused to as if ColdFusion is acting like a middle server where its getting the file in bits from the CDN and passing it to the user , OR is it downloading the entire file into memory and then streaming it to the user.
If its doing the latter, then how do I make it act as the middle server?
Using cfhttp downloads the file. There is not much recourse for hiding the URI for the CDN without downloading the file and re-serving it to the end user.
Most end-users will not be able to tell where the file is located if you use the HTTP 301 or 302 status codes.
301 is a permanent redirect and 302 is a temporary redirect. The difference being some browsers cache 301's so that the user does not have to hit your server again if it requests the URI a second time.
You can do this simply
<cfheader statuscode="301" statustext="Moved permanently" />
<cfheader name="Location" value="#CDN_URI#" />
<cfabort />
or
<cfheader statuscode="302" statustext="Moved Temporarily" />
<cfheader name="Location" value="#CDN_URI#" />
<cfabort />
You can also use cflocation, which by default uses a 302, but can be made to use another status code using the statusCode attribute.
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_j-l_04.html
精彩评论