A problem and two questions

Last post 02-07-2011, 11:51 AM by BHill. 5 replies.
Sort Posts: Previous Next
  •  02-04-2011, 11:43 AM 66061

    A problem and two questions

    Problem: I'm doing some pre-purchase testing of the uploader and have noticed a quirk that I'm hoping is simply a minor configuration error. For some reason, when test files are cancelled partway through the upload process, the uploaded portions are not removed from the temp directory. Because I'm dealing with very large files (1-2gb), this will lead to a rapid loss of disk space unless I write a scheduled job to clean it out regularly. Is this the proper behavior for the uploader, or should these files be cleared automatically?
     
    Question 1: Is there a way to execute code when a user cancels an upload, similar to the Uploader_FileUploaded method? We are collecting additional information associated with the files and need to massage that data a bit when they cancel an upload. I only see the FileUploaded and ErrorMethods, but I can't be the first person to face this question. What is the best way to execute server side code on postback when a user cancels an upload?
     
    Question 2: Your documentation is a bit unclear on the process for limiting upload speed. I found the reference to adding the key UploadSpeedKB to the web.config file, but the documentation doesn't mention where to place it. I initially loaded it into the ConfigurationSettings>AppSettings  portion of the file, which had no effect on the upload speed. Copying it into other portions of the file also had no impact. Where, exactly, am I supposed to put this? I should mention that this is a .Net 3.5 app operating on IIS 7.5 (Windows Server 2008 R2).
  •  02-04-2011, 12:44 PM 66063 in reply to 66061

    Re: A problem and two questions

    Dear BHill,
     
    You do not need take care the temp files.
    Temp file means the uploaded data & info of a file. it's owned by uploader , not your application. 
    Temporary files will be deleted after 5 hours (if the page load again after 5 hours). 
    If you would like to remove temporary files once upload is finished, you can use the following code:
    protected void attachment1_FileUploaded(object sender, UploaderEventArgs args)
        {
             //save upload file to another folder
             //you can change the upload file name here, like args.CopyTo("~/savefolder/"+"myname.jpg");
            args.CopyTo("~/savefolder/"+args.FileName);
             //delete the temporary files
            args.Delete();
        }
    You can't cancel the ajaxuploader at server side because while the files being uploaded, the server code is not executing.
     
    Please open your application web.config, add the following snippet to your web.config and test it again:
    <appSettings>
      <add key="CuteWebUI.AjaxUploader.UploadSpeedKB" value="20" />
     </appSettings>
     
    Thank you for asking
     
  •  02-04-2011, 12:44 PM 66064 in reply to 66061

    Re: A problem and two questions

    Dear BHill,
     
    You do not need take care the temp files.
    Temp file means the uploaded data & info of a file. it's owned by uploader , not your application. 
    Temporary files will be deleted after 5 hours (if the page load again after 5 hours). 
    If you would like to remove temporary files once upload is finished, you can use the following code:
    protected void attachment1_FileUploaded(object sender, UploaderEventArgs args)
        {
             //save upload file to another folder
             //you can change the upload file name here, like args.CopyTo("~/savefolder/"+"myname.jpg");
            args.CopyTo("~/savefolder/"+args.FileName);
             //delete the temporary files
            args.Delete();
        }
    You can't cancel the ajaxuploader at server side because while the files being uploaded, the server code is not executing.
     
    Please open your application web.config, add the following snippet to your web.config, it will limit the upload speed:
    <appSettings>
      <add key="CuteWebUI.AjaxUploader.UploadSpeedKB" value="20" />
     </appSettings>
     
    Thank you for asking
     
  •  02-04-2011, 1:12 PM 66068 in reply to 66063

    Re: A problem and two questions

    That resolves two of the three things I posted. Using the longer form of the key in the web.config file is working, and I had missed the args.delete method (the volume of the files is high enough that we don't want them sticking around for 5 hours). Thanks!
     
     
    As for the third thing, I don't think I was clear in what I was asking. I don't want to cancel the file upload using server side code. I want to execute server side code immediately after the USER clicks the cancel button.
     
    For example, I see in the documentation that the Uploader class has the OnUploadCompleted instance method that is executed when a file upload finishes. There are also a number of other instance methods associated with the Uploader. Can you tell me if any of them are called when the user clicks the Cancel button?  I'm simply trying to figure out how to hook a method in my codebehind into the cancel event.
     
    I could write a custom clientside JS to handle this, but I'm hoping that there's something built in.
  •  02-06-2011, 4:21 PM 66083 in reply to 66068

    Re: A problem and two questions

    Dear BHill,
     
    The uploader doesn't provide server side or client side cancel event directly. 
     
    Thank you for asking
     
     
  •  02-07-2011, 11:51 AM 66099 in reply to 66083

    Re: A problem and two questions

    Thanks. I'm using a custom Cancel button, so it should be trivial to hook a client side JS to the button to force a postback on click. Do you happen to know whether any of your other customers have tried this, or whether doing so might cause any problems?
View as RSS news feed in XML