This is a migrated thread and some comments may be shown as answers.

Rename file on FileUploadFailed

6 Answers 87 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 02 Aug 2009, 07:38 PM
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?

6 Answers, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 04 Aug 2009, 06:27 PM
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.
0
Scott
Top achievements
Rank 1
answered on 04 Aug 2009, 07:06 PM
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.
0
Ivan
Telerik team
answered on 05 Aug 2009, 11:37 AM
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.
0
Files Renamer
Top achievements
Rank 1
answered on 30 Apr 2010, 09:28 PM
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.
0
Aravind
Top achievements
Rank 1
answered on 30 Nov 2012, 11:14 AM

0
jonathan
Top achievements
Rank 1
answered on 25 Sep 2017, 07:57 PM
This is a great article. You can use this technique. Beside this- I have a software for bulk rename. My software works with all platform. For checking my software go to google.com and type- BatchRenameFiles Tool. Check the first result.
Tags
Upload
Asked by
Scott
Top achievements
Rank 1
Answers by
Ivan
Telerik team
Scott
Top achievements
Rank 1
Files Renamer
Top achievements
Rank 1
Aravind
Top achievements
Rank 1
jonathan
Top achievements
Rank 1
Share this question
or