Queries on the silverlight File uploader for SharePonit 2010.

3 posts, 0 answers
  1. veena
    veena avatar
    4 posts
    Member since:
    Jul 2011

    Posted 03 Aug 2011 Link to this post

    Hi,
    I was watching the following video on File Uploaded in Silverlight for SharEPoint 2010. I have few queries on that:

    http://tv.telerik.com/watch/silverlight/video/telerik-silverlight-controls-and-sharepoint-2010-part-5

    1. It is mentioned in the video that the ScratchArea folder is not required to chunk the files if we have enabled RBS.
    How it differs, where does the chunk data of the large file goes if we are not using / creating the folder.

    2. If i have a scenario where i am using the RBS feature of SharePoint 2010 only for files more than 10MB, in such a scenario how can i or where to put the if condition that if the file is less than 10 MB use the ScracthArea folder to chunk the large file . How we can achieve such a scenario?

    3. In the video there is a mention about the this.Request.Form["RadUAG_fileName"]. Now if the file is uploaded from 3-4 browsers by different users, how the file names will be?

    4. If we are enabling the RBS , whether the uploadhandler.ashx is required.  How different the project (Server Project-SharePoint Empty Project) will be in structure if we are using of have a facility to switch RBS and non-RBS implementation depending upon the size of the file.

    5. this video shows the silverlight webpart which is deployed to the SharePoint Page to upload the file. What if i have a silverlight application which is out of SharePoint environment, hosted in some other server. I want to upload a huge file from the silverlight application to the SharePoint Document Library.

    Thanks in advance.
    Veena R

     

  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 09 Aug 2011 Link to this post

    Hi Veena,

    Since this video is using old version of the RadUpload control, you might have to reconsider some of its logic. Basically with the last version of the control one upload request (i.e. one chunk) can contain multiple files and this means that there were some changes introduced in the RadUploadHandler implementation. More info you can find here. However, the main point of the video is still valid but you can implement it with a slightly different piece of code. I will get to that later. First let me get to your questions in the order you posted them:

    1. The ScratchArea folder is used to set the RadUpload TargetFolder property - The TargetFolder should point to the folder that is configured to accept the uploaded files. If no such folder is defined the files will be uploaded directly to the server. This is why defining a TargetFolder as the ScratchArea folder in this example, allows you to track the physical path of the uploaded files. This will help you easily access them later on in your implementation and place them in a SharePoint library. However, if you are using the RBS feature then the files will be automatically stored in the physical folder that you have defined for the feature. And you can use this folder to access the uploaded files once they are entirely uploaded. So basically the ScratchArea folder helps you locate and use the uploaded files to save them to a SharePoint library.

    2. You can place such an "if statement" in the RadUpload.UploadStarting() event handler (read more about the RadUpload events). You can evaluate the SelectedFile.Size  to determine the TargetFolder. If the size of the selected file is less than 10MB you can set the RadUpload.TargetFolder property to ScratchArea, else you don't have to define a TargetFolder.
    private void radUpload_FileUploadStarting(object sender, Telerik.Windows.Controls.FileUploadStartingEventArgs e)
    {
        if (e.SelectedFile.Size < 10000000)
            (sender as RadUpload).TargetFolder = "ScratchArea";
    }

    3. In the latest version of the RadUpload control you cannot get a parameter value using this syntax - this.Request.Form[key];. Instead you can get the name of the file using the GetFileName() method of the RadUploadHandler. Also since your scenario requires to upload multiple files with the same name but uploaded from different users, you can use the approach described here.
    4. The UploadHandler is required to handle the requests sent from the RadUpload control. This is why the setup of the SharePoint sever won't change the RadUpload-related structure of the project. Even when RBS is enabled, you will still need an http handler that derives form the RadUploadHandler to listen to the requests sent from the RadUpload control on the client-side. Moreover, the RadUploadHandler implementation allows you to customize the handler to better fit your requirements (read more).
    5. You should be able to implement this scenario out-of-the-box. Basically on the client side you need to define a path to the UploadHandler that will handle the upload request on the server. This is why if you can access the UplaodHandler on the SharePoint server from the server where the SL application is hosted, you should be able to use it to handle the uploads. However, cross domain issues might arise so you need to apply a proper cross-domain policy.

    Finally, with the latest version of the RadUpload control it is better to modify the UploadHandler by overriding the SaveChunkDate() method instead of the ProcessStream() method:
    public override bool SaveChunkData(string filePath, long position, byte[] buffer, int contentLength, out int savedBytes)
    {
        bool result = base.SaveChunkData(filePath, position, buffer, contentLength, out savedBytes);
        if(this.IsFinalFileRequest())
        {
            SPContext.Current.Web.AllowUnsafeUpdates = true;
            FileStream fStream = new FileStream(filePath, FileMode.Open);
            SPContext.Current.Web.Files.Add("/BigFiles/" + this.GetFileName(), fStream, true);
            fStream.Close();
            File.Delete(filePath);
                         
        }
    }

    I hope this information will help you.

    Best wishes,
    Tina Stancheva
    the Telerik team

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


  3. ramireddy
    ramireddy avatar
    2 posts
    Member since:
    Aug 2011

    Posted 31 Aug 2011 Link to this post

    hi,
    I have the same issue like the point 5th. as above. Is there are sample code to work around it.

    Thanks
Back to Top