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

Uploading same file name multiple times

14 Answers 678 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Lauren
Top achievements
Rank 1
Lauren asked on 09 Aug 2011, 05:03 PM
Hi all,

I've implemented a custom upload control.
when the user clicks on an Upload button, i do the following:
UploadControl.CurrentSession.SelectedFiles.Clear();
// Insert files to the RadUpload control
foreach (FileInfo file in FilesToUpload)
{
    RadUploadSelectedFile f = new RadUploadSelectedFile(file);
    UploadControl.CurrentSession.SelectedFiles.Add(f);
}
// Prepare and Start Upload process
UploadControl.PrepareSelectedFilesForUpload();
UploadControl.StartUpload();

I then rename each file on FileUploadStarting to make sure they have a unique name on the server.

The above works fine as long as all the selected file names are distinct.

The user would like to be able to upload multiple files with the SAME name (from different folders of course).
That's where i get a problem.

The UploadControl.CurrentSession.SelectedFiles do have let's say 2 files with the same name.
But FileUploadStarting is only called once. The second file is ignored.

Can you plesae help achieve the uplaod of multiple files with the same names ?

Thank you for your help.

14 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 12 Aug 2011, 02:29 PM
Hello Lauren,

Currently the RadUpload control uses only the file name as a unique identifier when deciding which files to be uploaded. This is needed to avoid sending over the net the same file twice. Unfortunately, due to the Silverlight security restrictions the RadUpload control can only access the name and size of the selected files. So only those two properties can be used to differentiate the files before upload.

This is why your scenario is not currently supported by the control. When you set two files with the same name for upload, since the control cannot access their full path, it cannot process them as different files and it processes only the first file. We added a feature request in our PITS to modify the RadUpload to take into account and the size of the files when differentiating the selected files for upload. This may help in your case, although if both the name and the size of the files are the same, the control still won't be able to distinguish them and will upload only one of them.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Brian
Top achievements
Rank 1
answered on 21 Oct 2011, 10:42 PM
Tina,
I am also having this problem.  I voted for the issue in PITS that you linked, but I think a better solution would be for the RadUpload to wait until after the FileUploadStarting event has been fired for every file before determining if there are duplicates by filename.  As the documentation notes, the FileUploadStarting event is our last chance to rename the file on the client, so the RadUpload control should give us until after that event to fix name conflicts ourselves.  That would allow Lauren and I to handle files that have the same name and size by renaming them ourselves before upload.  Under the current situation, and even under the proposed fix in PITS, we would be forced to tell users "you just can't do that", which is never a good answer.
0
Alex Fidanov
Telerik team
answered on 26 Oct 2011, 02:34 PM
Hello Brian,

The upload control will perform the validation as well as other calculations (like upload size, item size, max file count, etc.) when the files are selected, while the FileUploadStarting event is raised when the files start to upload. We need this information before this event is raised. When this issue is resolved and you are able to add files with same names, you can either use the UploadStarted/ UploadFileStarting events to check if files have duplicated names or use the RadUploadItem.Validate event for this.

Let me know if you have questions on this.

Best wishes,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Brian
Top achievements
Rank 1
answered on 26 Oct 2011, 02:46 PM
Alex,
I am fine with using those events instead as long as the control will accept the file renames at that time. 

My main concern is that users could still encounter a problem if they attempt to select two different files with the same name and size.  Under the proposed solution in PITS, only one of those files would be uploaded.  Perhaps an option could be added to disable this checking behavior?  In that case, the control would just upload whatever files are selected without trying to determine if the user has selected the same file twice.  If you need a unique identifier, perhaps a GUID or auto-incrementing integer could be used in this case?
0
Tina Stancheva
Telerik team
answered on 31 Oct 2011, 04:25 PM
Hi Brian,

Thank you for this feedback. It is highly appreciated and this is why I updated your Telerik account as a sign of our appreciation for these ideas. I also want to assure you that we will research all options when looking for a fix for this issue and we will definitely keep your suggestions in mind as well.

Please keep track of the item for more information on its progress.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Alex Fidanov
Telerik team
answered on 03 Nov 2011, 05:16 PM
Hello Brian,

Just to let you know that the approach that we have taken is to expose an event, that you will be able to handle and change the name of the file manually. As of Q3 2011, DuplicateFileNameFound event is available on the RadUpload control and you will be able to set new name through the event args' NewFileName property.

If you do not handle this event and do not provide an unique name, one will be generated automatically for you.

Please let me know if you have suggestions or questions on this.

All the best,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Brian
Top achievements
Rank 1
answered on 03 Nov 2011, 05:19 PM
Alex,
This sounds like a great solution.  I eagerly await the full release of Q3 so I can try it out.
0
Dave Navarro
Top achievements
Rank 2
answered on 19 Nov 2011, 02:36 AM
Hello,

I have a situation where I'm getting a new file name from our SQL Server. During the 'uploadStarting' event I attempt to pause the upload function so I can retrieve the new name. However the upload doesn't pause and continues to upload the file with the original name. This happens as the other code is off getting the new name.

When the new name is returned the uploaded file is long gone.

Will the new Q3 fix solve this problem too?

Please let me know and thanks!

~ Dave
0
Tina Stancheva
Telerik team
answered on 23 Nov 2011, 10:00 AM
Hello Dave,

I know you workaround the issue by taking another approach in your solution. However, in case anyone else from the community encounters the same issue, I want to point out that pausing the upload in the UploadStarting event handler is not a supported scenario. And the PauseUpload() method won't affect the upload process in this case.

Greetings,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Dave Navarro
Top achievements
Rank 2
answered on 23 Nov 2011, 10:07 PM
Hello,

Yes, I found a work around that allowed me to use the upload control in a more standard way and then apply some 'post processing' on the files via an application server that runs as a Windows Service.

In case anyone is wondering, Q3 did not change how the 'pauseUpload' method works and it did not pause the upload once the 'uploadStarting' event had fired.

Also, by keeping the upload code 'simple' in the GUI it will help ensure that our code works with future versions of the upload control since we're not pushing it in ways that aren't common.

I hope this helps,

~ Dave
0
Mike
Top achievements
Rank 1
answered on 03 Feb 2012, 05:24 PM
When is the DuplicateFileName event raised? I am handling the DuplicateFileName event, but it is not ever being raised. We would like to show each of the multiple (duplicate) items in the RadUpload panel, but I am unable to see the event in order to rename the files. Are there any property settings which might prevent the RadUpload from raising DuplicateFileName?

I'm using the latest release of the Telerik RadControls for SIlverlight (2011.3.1220.1040)
0
Tina Stancheva
Telerik team
answered on 08 Feb 2012, 02:27 PM
Hi Mike,

Just to follow up on this issue in case anyone else from the community encounters it:

The DuplicateFileName event will be fired only if you add two files with the same name to the same upload session of the RadUpload. However, there is an issue with firing the event when dropping files in the RadUpload or the RadUploadDropPanel - the event isn't fired at all if the RadUpload control is processing dropped data. However this issue is already fixed and the fix will be available with the upcoming release later this month.

Regards,
Tina Stancheva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Zaheer
Top achievements
Rank 1
answered on 24 Feb 2015, 11:47 AM
Hi,

I am using Version=2014.1.403.45 and having this issue. Is there any work around for this?
0
Kiril Vandov
Telerik team
answered on 26 Feb 2015, 08:28 AM
Hello Zaheer,

I would like to ask you to open a new thread and describe the issue that you encountered there. In the current thread there are several listed issues that are resolved and I am not sure to which one you refer to. Also this will help us to better track the communication and give an answer based on your custom scenario.

Kind regards,
Kiril Vandov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Upload
Asked by
Lauren
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Brian
Top achievements
Rank 1
Alex Fidanov
Telerik team
Dave Navarro
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Zaheer
Top achievements
Rank 1
Kiril Vandov
Telerik team
Share this question
or