RadUpload for Moss 2007

14 posts, 0 answers
  1. Rana Pratap
    Rana Pratap avatar
    16 posts
    Member since:
    Sep 2009

    Posted 11 Oct 2009 Link to this post

    Hi ,

    I want use RadUpload control for uploading files to sharepoint document library but i cant reference microsoft.sharepoint.dll into silverlight application . can you suggest me the best way to do this.

    Thanks in advance
    Regards,
    Rana Pratap
  2. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 12 Oct 2009 Link to this post

    Hello Rana,

    Thank you for your interest in the RadUpload for Silverlight.

    The way to accomplish your task is to write a custom upload handler and inside it to populate the Sharepoint's database (instead of writing the uploaded file to the file system). Below are "how-to" instructions:
    • Write a common upload application - nothing special here;
    • Create a custom upload handler. link-1 and link-2;
      • Reference microsoft.sharepoint.dll;
      • Override the ProcessStream method;
      • Use the ChunkTag mechanism;
      • Save the uploaded data in Sharepoint instead in a local file.
    Please follow the RadUpload ChunkTag or how to deal with uploaded files by chunk example, it is similar to your case (except Sharepoint related stuff).

    More articles about RadUpload for Silverlight you can find in our online knowledge base repository.

    We hope this information will help you.

    Greetings,
    Ivan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft banner
  4. Jimmy Jou
    Jimmy Jou avatar
    3 posts
    Member since:
    Jul 2009

    Posted 29 Nov 2009 Link to this post

    Is there an API I can call to get the chunk of data so that they can be saved to SharePoint incrementally without saving to a local file sytem?
  5. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 02 Dec 2009 Link to this post

    Hi Jimmy Jou,

    You can modify the upload handler and implement your custom logic there:
    http://www.telerik.com/help/silverlight/creating_custom_server-side_handler.html

    Regards,
    Valentin.Stoychev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Jimmy Jou
    Jimmy Jou avatar
    3 posts
    Member since:
    Jul 2009

    Posted 02 Dec 2009 Link to this post

    That's exactly the question I am asking: how to get hold of the file stream if I don't want to save it to a file first. In another words, how can I get the file stream is a byte[] form?

    The link says: Insert here your custom logic for processing the file stream

    Jimmy
  7. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 07 Dec 2009 Link to this post

    Hello Jimmy,

    Thank you for contacting us.

    Actually there are two main points you should be aware when you customize your upload-handler.
    1. Initializing the Chunk-Tag in order to track your files. Please note the ChunkTag is of type String. There are two places you can embed the initialization code in depending on the approach you prefer in step-2:
       
      public override void ProcessStream()
      {
          string chunkTag = this.FormChunkTag;
          if (this.IsNewFileRequest())
          {
              // Generate a new ChunkTag in order to tag all chunks.
              chunkTag = MyUniqueKeyGenerator.GetKey.ToString();
          }
          this.ResultChunkTag = chunkTag;
          ...

      or:
       
      public override bool InitializeChunkStorage(string filePath)
      {
          if (this.IsNewFileRequest())
          {
              this.ResultChunkTag = MyUniqueKeyGenerator.GetKey();
          }
          else if (this.FormChunkTag != null)
          {
              this.ResultChunkTag = this.FormChunkTag;
          }
          ...
       
      In your code you will use the Chunk-Tag value to save all chunks in one place.
       
    2. Save the uploaded data. Here you have two options:
      • Override the InitializeChunkStorage and the SaveChunkData methods. This is the easiest approach.
      • Rip and modify all the original ProcessStream method. This is more difficult approach as you should care about all internal return-parameters.

    In the attached archive you can find a project-skeleton that implements the overriding of the InitializeChunkStorage and the SaveChunkData methods. Please note nothing is saved at the server-side - You should add your custom code in order to save the uploaded content - the original code is still inside these methods but commented.

    Please give it a try and let us know if you need further assistance.

    Kind regards,
    Ivan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Laks
    Laks avatar
    4 posts
    Member since:
    Feb 2010

    Posted 07 Mar 2010 Link to this post

    Hello There,

    I am trying to use the same example to upload a document in to the sharepoint document library.

    I am not able to include the web dll into the bin folder. Whenever I include the dll with this implementation, my sharepoint application breaks and it doesnt allow the rad handler to be over ridden.

    I am trying to use the follwing code for the SAVECHUNKDATA method

    public override bool SaveChunkData(string filePath, long position, byte[] buffer, out long savedBytes) 
            { 
                bool success = false
                savedBytes = 0; 
                try 
                { 
                    UploadFile1(buffer, "http://myserver/toolkit/ManagementDocuments/Forms/" + this.GetFileName()); 
                    // Place your Save-in-DB code here. 
                    savedBytes = buffer.Length; 
     
                    // Note: do not forget to set the success value: 
                    success = true
                } 
                catch (Exception e) 
                { 
                    throw new Exception(e.Message); 
                } 
     
                if (!success) 
                { 
                    string fileName = this.GetFileName(); 
                    this.AddReturnParam(RadUploadConstants.ParamNameMessage, String.Format("Cannot save the file: [{0}]", fileName)); 
                } 
                return success; 

    Please suggest a way to rectiy this.

    Regards,
    Laks






  9. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 08 Mar 2010 Link to this post

    Hello Laks,

    Thank you for contacting us.

    We are not sure why the moss-application rejects the upload dll. Please note you should reference the Telerik.Windows.RadUploadHandler.dll file (the upload handler library). Are there some special permissions that prevent referencing of our library?

    About the code inside the SaveChunkData - it looks pretty good. However I would like to point the call of the UploadFile1 method. Are you sure about it? Could you try to comment it in order to check the handler's behavior.

    Looking forward for your reply.

    Kind regards,
    Ivan
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  10. Laks
    Laks avatar
    4 posts
    Member since:
    Feb 2010

    Posted 08 Mar 2010 Link to this post

    Here is the complete code. I have tried deplying the dll after removing the save method, it worked. Please let me know if you find anything

            public override bool SaveChunkData(string filePath, long position, byte[] buffer, out long savedBytes) 
            { 
                bool success = false
                savedBytes = 0
                try 
                { 
                    UploadFile1(buffer, "http://myserver/toolkit/Management%20Documents/Forms/" + this.GetFileName()); 
                    // Place your Save-in-DB code here. 
                    savedBytes = buffer.Length; 
     
                    // Note: do not forget to set the success value: 
                    success = true
                } 
                catch (Exception e) 
                { 
                    throw new Exception(e.Message); 
                } 
     
                if (!success) 
                { 
                    string fileName = this.GetFileName(); 
                    this.AddReturnParam(RadUploadConstants.ParamNameMessage, String.Format("Cannot save the file: [{0}]", fileName)); 
                } 
                return success; 
     
     
    public void UploadFile1(byte[] contents, string destUrl) 
        SPWeb site = new SPSite(destUrl).OpenWeb(); 
        site.Files.Add(destUrl, contents); 

    Thanks
  11. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 11 Mar 2010 Link to this post

    Hello Laks,
     
    Thank you for the sample code.
     
    Now I've figure the issue out - in your sharepoint-related code you add a new file for each uploaded chunk. But the method you are relying on returns an error if the file already exists. Even more all the SPFileCollection.Add methods cannot append a piece of data - they always treat the supplied data as the whole file's content. Because of this you have two options:
     
    • If you depend on the SP's original API you should save the uploaded file to the file system first, and after the final file-request to save the file into SP.
    • If you still prefer to avoid the intermediate save to the file system, you should rely on a third party library.
     
    We hope this information will help you.
     
    Best wishes,
    Ivan
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  12. Laks
    Laks avatar
    4 posts
    Member since:
    Feb 2010

    Posted 23 Mar 2010 Link to this post

    Thanks for your help
  13. IT Support
    IT Support avatar
    4 posts
    Member since:
    Mar 2010

    Posted 02 Apr 2010 Link to this post

    note that the way you are adding the file by opening the SPSite and SPWeb this way leads to memory leak.

    Be sure to dispose them after use.

    using(SPSite oSPsite = new SPSite(destUrl))
    {
      using(SPWeb oSPWeb = oSPSite.OpenWeb())
       {
           
    } }


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

    Posted 31 Aug 2011 Link to this post

    HI,
    I am developing application using silverlight 4 but I need to upload my documents to Sharepoint 2010. Can I use the procedure as above,
    is there any other way to do it.
    Please let me know...........I using the same RadUpload Control for it.

    Thanks
    Ram
  15. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 05 Sep 2011 Link to this post

    Hi Ram,

    You can follow this tutorial http://tv.telerik.com/watch/silverlight/video/telerik-silverlight-controls-and-sharepoint-2010-part-5 as it will get you on the right track.

    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.

    I hope this information will help you. However, if we can further assist you, please let us know.

    Greetings,
    Tina Stancheva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Back to Top
DevCraft banner