Asynchronous action inside CFC function

2012-11-13 Thread Christophe Maso

Hi I have a function that gets some binary data, uses that data to do a cffile 
action=write, and then returns the file's path as a string. I'm experiencing a 
problem that suggests the function is doing the return before the write action 
has completed. In the code below, will the function wait for the write action 
to complete before it sends the return? I'm almost certain it will not; is 
there a way to force the function to wait for the write to complete before it 
returns strWPTempFilePath, such as cftransaction or something along those lines?

cfset strWPTempFilePath = request.stcApplicationData.strTempImageDirectory  
createUuid()  .pdf
cffile action=WRITE file=#strWPTempFilePath# output=#r_docBinData# 
addNewLine=no /
cfreturn strWPTempFilePath 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:353141
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Asynchronous action inside CFC function

2012-11-13 Thread Russ Michaels

You could use a do while file not exists loop to wait till the file gets
written.

Regards
Russ Michaels
On Nov 13, 2012 5:26 PM, Christophe Maso zum...@hotmail.com wrote:


 Hi I have a function that gets some binary data, uses that data to do a
 cffile action=write, and then returns the file's path as a string. I'm
 experiencing a problem that suggests the function is doing the return
 before the write action has completed. In the code below, will the function
 wait for the write action to complete before it sends the return? I'm
 almost certain it will not; is there a way to force the function to wait
 for the write to complete before it returns strWPTempFilePath, such as
 cftransaction or something along those lines?

 cfset strWPTempFilePath =
 request.stcApplicationData.strTempImageDirectory  createUuid()  .pdf
 cffile action=WRITE file=#strWPTempFilePath# output=#r_docBinData#
 addNewLine=no /
 cfreturn strWPTempFilePath

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:353142
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm