Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Wait for create image to complete...

Guest
Sep 15, 2010 Sep 15, 2010

I have an application that uses function in a cfc file. One function creates a jpeg from a byte array. This works fine. However, if I"m updating the image I need Flash to wait for the image to be created before it trys to reload it. How do I modify my code to wait and not do the return until the cffile action is complete?

<!-- save jpeg -->
<cffunction name="createJpeg" access="remote" output="false" returntype="boolean">
  <cfargument name="send_image_data" type="string" required="yes">
  <cfargument name="send_image_path" type="string" required="yes">

    <cfset bindecode = BinaryDecode(send_image_data, "Base64")>
    <cfset pathtowrite='#send_image_path#'>
<cffile action="write" file="#pathtowrite#" output="#bindecode#" nameconflict="overwrite" />

<cfreturn "1">
</cffunction>

Thanks!

417
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 17, 2010 Sep 17, 2010

I'm thinking you can probably use a <cfloop> tag to check for the file.  Maybe you can try to read it in a loop?  You'll want to have a timeout so that if there's a problem the whole thing doesn't hang.  My coldfusion is a bit iffy but In pseudo code something like this....

set start = Now()

loop

    if read file exit loop

    if Now()-start GT 180 exit loop

    sleep(1000)

endloop

Othewise, maybe using sleep() to wait for long enough to process the image way also work, though less efficient.

Hope this helps

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 21, 2010 Sep 21, 2010
LATEST

Try using FileOpen(), FileWrite(), and then FileClose() instead of cffile.  Let me know how that goes for you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources