Rename file on FileUploadFailed

6 posts, 0 answers
  1. Scott
    Scott avatar
    43 posts
    Member since:
    Nov 2007

    Posted 02 Aug 2009 Link to this post

    If during a file upload, I encounter a RadUpload_FileUploadFailed event and I determine it is due to a duplicate file name, how can I rename that file by adding a "2" after it and then attempting the save again?
  2. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 04 Aug 2009 Link to this post

    Hi Scott,

    Thank you for interest in the Radupload control.

    Please preview the Saving files with unique name on the server using RadUploadHandler article. There are an example and the explanation you are looking for.

    We hope this information will help you. Of course if you have more question do not hesitate to contact us.

    All the best,
    Ivan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Scott
    Scott avatar
    43 posts
    Member since:
    Nov 2007

    Posted 04 Aug 2009 Link to this post

    Thanks for your reply.  I read that article and can rename and save files just fine.  My question is if the rename FAILS and I catch it, I want to rename again and re-upload.  I can't figure out how to programmatically restart the upload when the RadUpload_FileUplaodFailed event is triggered.
  5. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 05 Aug 2009 Link to this post

    Hello Scott,

    Thank you for the clarification.

    Actually there are two main approaches to rename uploaded files
    1. Client side.
      This is the easiest way and it was already described in the How to upload a file with a different name article.
      Pros: The upload handler was not modified - actually you can use any existent handler to receive the uploaded file.
      Cons: This not an appropriate technique for realizing an unique file name.
    2. Server side.
      File rename process is implemented in the upload handler and the client code my not participate.
      Pros: This is the better way to get an unique file name. Actually you can try as many different names as you want.
      Cons: The upload handler is a specialized one.
      Here you have two different ways:
      1. Rename at the and of the upload process.
        Not so sophisticated approach. Even more you can override an existing file or another uploader can override your file. Here you should override the ProcessStream method and inside it you should wait for the final upload chunk like in the code below:
        public override void ProcessStream() 
            base.ProcessStream(); 
         
            // Check if this is the last chunk 
            if (this.IsFinalFileRequest()) 
            { 
                // here you can do your Custom Action 
            } 
        The good example is the Process files on the server after upload article. Here names of all successfully uploaded files are collected by the client code and resend to the upload handler. Note, the custom process (rename process) starts after all files are uploaded.
      2. Rename at beginning of the upload process.
        This is the best approach and it is described in the Saving files with unique name on the server using RadUploadHandler article. Actually you can use this technique to upload files in a temp folder and only after successful upload to publish them in the official folder.

    Please note the RadUpload can not re-upload files neither after successful upload nor after failed one. This is the reason we have advised you already to use the Saving files with unique name on the server using RadUploadHandler approach.

    Let us know if we can assist you further.

    Regards,
    Ivan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Files Renamer
    Files Renamer avatar
    1 posts
    Member since:
    Apr 2010

    Posted 30 Apr 2010 Link to this post

    I really use that kind of information my works get more easier that before. I am currently File Renamer and now its going so easy.
  7. Aravind
    Aravind avatar
    9 posts
    Member since:
    Oct 2012

    Posted 30 Nov 2012 Link to this post


Back to Top
DevCraft banner