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

Assistance with Upload and SharePoint 2010

3 Answers 99 Views
Upload
This is a migrated thread and some comments may be shown as answers.
DogEars
Top achievements
Rank 2
DogEars asked on 22 Sep 2011, 11:51 PM
I'm having a devil of a time getting this to work.

I have a requirement to upload directly to a SP library, so I'm using the following code inside an UploadHandler.cs file:
public class UploadHandler : RadUploadHandler
    {
        public override void ProcessStream()
        {
            base.ProcessStream();
 
            if (this.IsFinalFileRequest())
            {
                string filename = this.Request.Form["RadUAG_fileName"];
                string fullPath = @"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\FileUploadSP\FileTemp\";
                SPContext.Current.Web.AllowUnsafeUpdates = true;
                FileStream fs = new FileStream(fullPath + filename, FileMode.Open);
                SPContext.Current.Web.Files.Add("/UploadLibrary/" + filename, fs, true);
                fs.Close();
                File.Delete(fullPath + filename);
            }
 
        }
    }

I have build this using 2 projects. One a SL project that holds the control and the other a blank SP solution. Mapped it to the layouts folder and deploying it to a local dev. It GACs the dll correctly and everything looks like it should work. However, it crashes on me every single time I browse to the .ashx file or when I click the upload button, boom.

I was first getting a could not create type error, but I worked around that to make SP happy with the format. Now I get this error:
Exception information:
    Exception type: HttpParseException
    Exception message: Exception of type 'System.Web.HttpParseException' was thrown.
  
Request information:
    Request path: /_layouts/FileUploadSP/UploadHandler.ashx
    User host address: fe80::543f:cf7d:803d:6749WSS_Minimal
    User: CRMDEV\Administrator
    Is authenticated: True
    Authentication Type: NTLM
    Thread account name: CRMDEV\Administrator

I know the .ashx file is fine because I set it up to read from a different helloworld type class. But whenever I go for the radupload it blows on me. From what I have read your upload implements the IHttpHandler, but I'm wondering if it does now? Am I just missing something simple here?

Here is my .ashx for reference:
<%@ Assembly Name="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ WebHandler Language="C#" Class="FileUploadSP.TestClass, FileUploadSP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7c8e2c3ef53023ee" %>

And finally my XAML for the control itself:
<UserControl x:Class="FileUploadSL.MainPage"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
 
    <Grid x:Name="LayoutRoot" Background="White">
<telerik:RadUpload x:Name="RadUpload1"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Top"                       
                           IsAppendFilesEnabled="True"
                           IsAutomaticUpload="False"
                           MaxFileCount="10"
                           MaxFileSize="100000000"
                           MaxUploadSize="200000000"
                           OverwriteExistingFiles="True"
                           TargetFolder="FileTemp"
                           BufferSize="512"
                           UploadServiceUrl="/_layouts/FileUploadSP/UploadHandler.ashx" />
    </Grid>
</UserControl>


This is SP2010 on Server 2008 R2 of course with SQL 2008 R2, if it matters at all.

If anyone could give me any guidance on this I would appreciate it. I've been tearing my hair out all day and I could really use some help.

I have made the entire project available here for someone from support to take a look at. Download Solution

Thanks!

3 Answers, 1 is accepted

Sort by
0
DogEars
Top achievements
Rank 2
answered on 24 Sep 2011, 12:08 AM
I finally figured out how to turn off the custom error stuff, didn't know there was another web.config in the _layouts folder.

So I'm receiving the following error:

Could not load file or assembly 'Telerik.Windows.RadUploadHandler, Version=2011.2.712.35, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The system cannot find the file specified.

What do I need to do to get this resolved? Is there a specific .dll to GAC?
0
DogEars
Top achievements
Rank 2
answered on 24 Sep 2011, 06:39 AM
If anyone from support or that knows reads this thread.

All I really want to know is what .dll files I need to GAC for this to be resolved and if I need any safe control or handler entries in the web.config for everything to work in SharePoint.

Thanks.
0
Tina Stancheva
Telerik team
answered on 28 Sep 2011, 09:24 AM
Hi Dogears,

When you add the Telerik.Windows.RadUploadHandler.dll in the SharePoint solution you need to make sure that the dll is included into the SharePoint project Package:


Also, it is better to override the SaveChunkData method in the UploadHandler, rather than the ProsessStream. I attached a sample project demonstrating how you can implement your scenario. Let us know if we can further assist you.

All the best,
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
DogEars
Top achievements
Rank 2
Tina Stancheva
Telerik team
Share this question
or