Upload doesn't work in production environment

2 posts, 0 answers
  1. Helge
    Helge avatar
    1 posts
    Member since:
    Jan 2012

    Posted 03 Jan 2012 Link to this post

    Hi,

    I have created an Silverlight app that implements the RadUpload component by following Sahil Malik's video (http://blah.winsmarts.com/2010-3-Large_File_Upload_in_SharePoint_2010.aspx). The upload path is to the SharePoint 14-hive (a custom folder) and is handled by a custom HttpHandler. This works just fine on my dev server (VMWare image), but when I deploy this to my client's prod server, I get the following error:
    "Cannot save the file: [Access to the path 'c:\program files\common files\microsoft shared\web server extenstions\14\template\layouts\<my project name>\Scratcharea\<my file name>' is denied]"
    The error message is shown as a tooltip on a little 'alert' icon to the right of the selected file to upload.

    I haven't done anything in regards to setting permissions to the destination folder in either environment.

    PS. The Silverlight app is hosted in SharePoint 2010.

    Any ideas?

    Thanks!
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 06 Jan 2012 Link to this post

    Hi Helge,

    This video is using an old version of the RadUpload control and this is why you might have to reconsider some of its logic. 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.  Basically now instead of using this syntax - this.Request.Form[key]; to get the name of the file it is recommended to get it through the GetFileName() method of the RadUploadHandler.

    Also 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, thus writing the following UploadHandler implementation:
    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);
        }
    }

    Please make the above modifications and test your code again as they can help.

    Also, it is important to check if the SharePoint user has the proper rights for creating files under the Scratcharea folder as if the user can't access the folder, then the RadUpload control won't be able to access it as well and the uploaded files won't be saved thus causing the "Cannot save the file" error message.

    I hope this information will help you.

    Kind regards,
    Tina Stancheva
    the Telerik team

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

  3. DevCraft banner
Back to Top