Using the web services to upload documents to chosen librari

Posted by Community Admin on 03-Aug-2018 22:36

Using the web services to upload documents to chosen libraries?

All Replies

Posted by Community Admin on 03-Mar-2011 00:00

Hi,

I am looking to upload documents to my Sitefinity site, using the web services provided out-of-the-box. In particular, documentlibrary/document. These two web services seem very similar.

In specific, I have a few document libraries I setup. Is it possible to selectively choose which library to upload to? Looking at this url:

theplaygrounds.co.uk/.../

I don't see where I specifiy the document library name? Is it in parentId?


Thanks

Posted by Community Admin on 04-Mar-2011 00:00

Hi G S S,

The ParentID is the a parameter that represents the library ID.

Greetings,
Ivan Dimitrov
the Telerik team

Posted by Community Admin on 04-Mar-2011 00:00

Hi,

In the libraries I have setup. I don't see an ID, however? Where can I get this from?        

Thanks

Posted by Community Admin on 07-Mar-2011 00:00

Hi G S S,

You can use the fluent API to get the IDs.

             App.WorkWith().DocumentLibraries().ForEach(lib =>
               
                    var id = lib.Id;
                );

All the best,
Ivan Dimitrov
the Telerik team

Posted by Community Admin on 26-Sep-2011 00:00

I do not see where I can define streams or bytes for the actual file. Is it possible to upload a file remotely to Sitefinity from another system via web service? I would image it would involve sending a blob or posting a file remotely to Sitefinity?

Posted by Community Admin on 27-Sep-2011 00:00

Hi Basem,

The LibrariesManager has a method

virtual void Upload(MediaContent content, Stream source, string extension)

where you can pass the stream

          var album = this.CreateLibrary<DocumentLibrary>(albumTitle);
            albumId = album.Id;
            var manager = LibrariesManager.GetManager();

            var document = manager.CreateDocument();
            document.Parent = album;
            document.Title = title;
            document.UrlName = title.ToLower().Replace(' ', '-');

            using (var stream = ImageStream())
           
                manager.Upload(document, stream, ".jpeg");
           
            manager.Publish(document);

            manager.SaveChanges();

private Stream ImageStream()
       
            System.Drawing.Image imgThumb = new Bitmap(100, 100, PixelFormat.Format24bppRgb);
            MemoryStream ms = new MemoryStream();
            System.Drawing.Bitmap b = new System.Drawing.Bitmap(imgThumb);
            Graphics objGraphics = Graphics.FromImage(b);
            Font objFont = new Font("Arial", 40, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
            objGraphics = Graphics.FromImage(b);


            objGraphics.Clear(Color.White);
            objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
            objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
            objGraphics.DrawString("sampleImage", objFont, new SolidBrush(Color.FromArgb(000, 122, 102)), 0, 0);

            b.Save(ms, ImageFormat.Jpeg);
            return ms;
       


Greetings,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed