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

Is the UploadServiceUrl required?

1 Answer 81 Views
Upload
This is a migrated thread and some comments may be shown as answers.
DogEars
Top achievements
Rank 2
DogEars asked on 29 Sep 2011, 12:21 AM
I'm trying to construct a stand-alone web resource for CRM and I'm wondering if I have to provide an upload handler to the control?

I had planned to just do something like this using the SharePoint Client Object Model from the FileUploading event in my xaml code behind:

public void UploadDocument(string siteURL, string documentListName, string documentListURL, string documentName, byte[] documentStream)
       {
           using (ClientContext clientContext = new ClientContext(siteURL))
           {
               //Get Document List
               List documentsList = clientContext.Web.Lists.GetByTitle(documentListName);
               var fileCreationInformation = new FileCreationInformation();
               //Assign to content byte[] i.e. documentStream
               fileCreationInformation.Content = documentStream;
               //Allow owerwrite of document
               fileCreationInformation.Overwrite = true;
               //Upload URL
               fileCreationInformation.Url = siteURL + documentListURL + documentName;
               Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(fileCreationInformation);
               //Update the metadata for a field having name "DocType"
               //uploadFile.ListItemAllFields["DocType"] = "Favourites";
               //uploadFile.ListItemAllFields.Update();
               clientContext.ExecuteQuery();
           }
       }

So is this possible or does the control need to offload to a handler to perform this type of action?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 03 Oct 2011, 03:53 PM
Hi Dogears,

The RadUpload control basically has two sides - the client side UI and the server-side handler. And when you hit the Upload button of the control, it will send a request to the server and if there isn't an RadUploadHandler that can handle the upload, an exception will be raised and the control will display it.

You can implement your scenario and cancel the upload using the RadUpload.CancelUpload() method but again the RadUpload will be in the appropriate visual state - canceled upload. This is why I believe it would be better to create a custom upload control. For example you can create a ListBox to display the list of selected items that you can select through the OpenFileDialog.

However, if you want to use the RadUpload control to upload files to a SharePoint sever,you can follow this tutorial http://tv.telerik.com/watch/silverlight/video/telerik-silverlight-controls-and-sharepoint-2010-part-5. I also attached a sample project where the approach described in the video tutorial is used. Please, note that the UploadHandler implementation in the attached solution is different from the one demonstrated in the video tutorial. This is due to the improvements in the RadUpload control and it is best to use the UploadHandler implementation from the attached solution.

Greetings,
Tina Stancheva
the Telerik team

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

Tags
Upload
Asked by
DogEars
Top achievements
Rank 2
Answers by
Tina Stancheva
Telerik team
Share this question
or