I am a newbie with ColdFusion and Flex. I am trying to implement file download/streaming functionality in my Flex 4.5 application and I am running ColdFusion 9 as my back end. More specifically, I have a component in my Flex app that displays a list of files - some of these files can be available for opening (or "previewing") via the client. I want the client to be able to click a button and download the file from the ColdFusion server, after the appropriate security checks are performed (also in ColdFusion). Right now I am just trying to get the basic download functionality to work with a very simple cfc. Here is the cfc code:
<cfcomponent displayname="Preview Document"
output="false">
<cffunction name="streamFile" access="remote" returntype="any">
<cfargument name="filename" displayName="Filename" type="string" required="true" />
<cfheader name="Content-Disposition" value="attachment;filename=#filename#" >
<cfcontent type="application/unknown" file="c:\myserverpath\#filename#">
</cffunction>
</cfcomponent>
When I try this via a cfm, it works fine (I get a File Download window where I can choose to either open or save the file). But when I try to use this in my Flex app, I get an error.
In my Flex app, I have a RemoteObject to access my cfc and a CallResponder:
<s:RemoteObject id="PreviewDocument"
source="PreviewDocument"
destination="ColdFusion"
showBusyCursor="true"/>
<s:CallResponder id="PreviewDocumentResult"
fault="Alert.show('CallResponder PreviewDocumentResult: ' +
event.fault.faultString + '\n' + event.fault.faultDetail)"
result="PreviewDocumentResult_resultHandler(event)"/>
Then I created a button whose click even executes the following line:
PreviewDocumentResult.token = PreviewDocument.streamFile(
When I run my app, I get the following fault:
faultCode = "Client.Error.DeliveryInDoubt"
faultString = "Channel disconnected"
faultDetail = "Channel disconnected before an acknowledgement was received"
I have tried many different approaches and searched online for help with this fault, but I could not find any helpful clue to where I can start investigating this.
Can anyone help with why I am getting this fault?
Thanks in advance.