Recovering from file transfer error

Last post 11-02-2009, 9:10 AM by cutechat. 1 replies.
Sort Posts: Previous Next
  •  11-01-2009, 8:41 AM 56834

    Recovering from file transfer error

    I am using UploadAttachments to upload multiple files and sometimes there are transmission errors of one or two files in the group.
     
    Any example/suggestion how to implement an automatic detection of errors and retransmission of the corrupted files?
     
    Thanks
     
     
  •  11-02-2009, 9:10 AM 56844 in reply to 56834

    Re: Recovering from file transfer error

    Hi,
     
    Please check this sample :
     
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    5.   
    6. <script runat="server">  
    7.   
    8.     protected void UploadAttachments1_FileValidating(object sender, UploaderEventArgs args)   
    9.     {   
    10.         if (args.FileSize > 10000)   
    11.             throw (new Exception("file should not larger then 10K"));   
    12.     }   
    13. </script>  
    14.   
    15. <html xmlns="http://www.w3.org/1999/xhtml">  
    16. <head runat="server">  
    17.     <title>Untitled Page</title>  
    18. </head>  
    19. <body>  
    20.     <form id="form1" runat="server">  
    21.         <div>  
    22.             <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1" OnFileValidating="UploadAttachments1_FileValidating">  
    23.             </CuteWebUI:UploadAttachments>  
    24.         </div>  
    25.         <div id="diverrormsg">  
    26.         </div>  
    27.     </form>  
    28.   
    29.     <script type="text/javascript">  
    30.        
    31.     var uploader=document.getElementById('<%=UploadAttachments1.ClientID %>')   
    32.     var currentfileresumecount=0;   
    33.     var currentfilename;   
    34.     var timesmsg=["first try","second try","third try"];   
    35.     function CuteWebUI_AjaxUploader_OnStart()   
    36.     {   
    37.         //this event fire at every file begin upload   
    38.         currentfileresumecount=0;   
    39.     }   
    40.     function CuteWebUI_AjaxUploader_OnError(msg)   
    41.     {   
    42.         uploader=this;   
    43.         var diverrormsg=document.getElementById("diverrormsg");   
    44.         if(currentfileresumecount<3)   
    45.         {   
    46.             uploader.setresumeoption("Resume");   
    47.             diverrormsg.innerHTML=currentfilename+" ("+timesmsg[currentfileresumecount]+") <hr/>"+msg;   
    48.             currentfileresumecount++;   
    49.         }   
    50.         else   
    51.         {   
    52.             uploader.setresumeoption("Cancel");   
    53.             diverrormsg.innerHTML=currentfilename+" have been cancelled after 3 times retry <hr/>"+msg;   
    54.         }   
    55.         return false;   
    56.     }   
    57.     function CuteWebUI_AjaxUploader_OnQueueUI(list)   
    58.     {   
    59.         for(var i=0;i<list.length;i++)   
    60.         {   
    61.             if(list[i].Status=="Upload")   
    62.                 currentfilename=list[i].FileName;   
    63.         }   
    64.     }   
    65.     </script>  
    66.   
    67. </body>  
    68. </html>  
     
    Regards,
    Terry
View as RSS news feed in XML