*urgent* Coldfusion zips/flex downloads the zip before zip is finished!


hi all,

 

i having trouble figuring out here.

i sending images coldfusion flex, , using cfzip create zip of images download.

i using fileref.download download zip user's computer in actionscript.

the problem flex let user download zip before finished compiling.

so if there 68 images in zip on webserver, depending on how fast select save location 42...or 29....etc.

 

i tried putting download function in return handler coldfusion remote object, fileref.download must executed mouse-click security reasons.

here click handler "download images" button.

here flex code below:

 

public function clickhandler1(event:event):void
            {   
                imgstylenumber = new arraycollection;           
                h = 0;
              
                randomfilenum = math.round(math.random()*(99999-11111))+11111;
               
                var t:int;
                (t = 0; t < hiresimagecollection.length; t++)
            {
               
                imgstylenumber.additem({ind:stylenumbercollection[h]+ "_" + colorcollection[h] + poricollection[h]}) ;
                h = h + 1;
            }   
               cfcquer4.getcartimages(hiresimagecollection,imgstylenumber,randomfilenum);
            
               
                downloadurl.url = "http://localhost/hib/imagestemp/downloadedimages" + randomfilenum + ".zip" + "?" + math.random();        
                 fileref.download(downloadurl, 'downloadedimages' + randomfilenum + '.zip');
            }

          

and here coldfusion cfc.

 

 


<cfcomponent>
   
<cffunction name="getcartimages" access="remote" returntype="any">   
    <cfargument name="hiresimagecollection" required="true">
    <cfargument name="imgstylenumber" required="true">
    <cfargument name ="randomfilenum" required="true">
   
    <cfset filepath = "c:\inetpub\wwwroot\hib\imagestemp\downloadedimages" & #randomfilenum# & ".zip">
    <cfset = 1>
   
    <cfloop index="image" array= #hiresimagecollection#>
        <cfset q = tostring(imgstylenumber[#i#].ind)>
        <cfset destpath = "c:\inetpub\wwwroot\hib\imagestemp\"& #q# &".jpg">
        <cfimage action="write" source= #image# destination= #destpath#>
        <cfzip action="zip" source= #destpath# file = #filepath# ></cfzip>
        <cffile action="delete" file= #destpath#> 
        <cfset = #i# + 1>
    </cfloop>
   
</cffunction>

 






























</cfcomponent>

 

 

 

 

 

thank needed help.

 

jk

jk,

 

you've got 2 competing things going on here: (1) cf receiving images , creating zip , (2) flex running download. as3 code fileref download method will, in scenario, run before cf done. event handlers solve problem, security constraints.

 

a slight change in as3 code fix it.

 

1. access cfc remoteobject (mx class or straight as3)

2. create listener function run when cf done work

3. in result handler, enable/show button call download method of fileref button's click event handler,

 

does make sense? it's way push off download method click handler after cf done. long key variables (downloadurl, etc.) not local function, , doesn't are, should easy change.



More discussions in ColdFusion


adobe

Comments

Popular posts from this blog

Error compiling for board Arduino/Genuino Uno.

Installation database is corrupt

esp8266 (nodemcu 0.9) client.write très lent ???