More in this section

Forums / Developing with Sitefinity / Custom library provider storing in physical path

Custom library provider storing in physical path

3 posts, 0 answered
  1. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    11 Nov 2009
    Link to this post
    Hi Team,

    After big grows of my Db for one public service web site i need use one custom provider to store the files in physical path. I have searched the older posts and lovely know if one final solution exist to store outside de db using one custom provider for 3.7+.

    http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/physical-upload-of-files-in-images-and-documents.aspx

    Thanks
    Romi.
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    12 Nov 2009
    Link to this post
    Hi Pierre,

    We haven't developed such provider yet, except the Amazon S3 one. Perhaps you can store your files on the Amazon S3 storage? The Libraries can work with that.

    Greetings,
    Georgi
    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. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    13 Nov 2009
    Link to this post
    Hi Georgi,

    I have tried implementing one custom provider but have some problems to store the new values for dimentions of my custom libraries. After overriding the SaveContent of one DefaultProvider class, the size and the with/height of my images are not correctly used. I explain about text in screen not about real dimention of image. For example size are always the original in edit Mode 1024x700(text). Height and width are correctly saved in metafields (i can see in the repeater of edited mode) but not used in the Template output where initials values are preserved. The image is dimentioned and stored but the metafileds is not clear.
    Some suggestion. Regards
    public override void SaveContent(IContent content, bool fireEvents)    
            {    
                CmsContentBase contentBase = null;    
                if (content is CmsContentBase)    
                {    
                    contentBase = (CmsContentBase)content;    
                }    
                else   
                {    
                    contentBase = this.SetContentBase(content);    
                }  
                if (Telerik.Cms.Engine.ImagesHelper.IsBrowserImage(content))  
                {  
                    long width = 0;  
                    long height = 0;  
     
                    object o2 = content.GetMetaData("Width");  
                    if (o2 != null)  
                        width = Convert.ToInt64(o2);  
     
                    o2 = content.GetMetaData("Height");  
                    if (o2 != null)  
                        height = Convert.ToInt64(o2);  
     
                    if (width > 900 || height > 500)  
                    {  
                        System.Drawing.Image img = System.Drawing.Image.FromStream(new System.IO.MemoryStream(content.Content as byte[]));  
                        img = Telerik.Cms.Engine.ImagesHelper.GenerateThumbnail(900, 500, img, true, true);  
     
                        System.IO.MemoryStream stream = new System.IO.MemoryStream();  
                        Telerik.Cms.Engine.ImagesHelper.SaveImageToStream(img, stream, content.MimeType);  
                        //content.Content = stream.GetBuffer();  
                        File.WriteAllBytes(GetFilePath(contentBase), stream.GetBuffer() as byte[]);  
                        contentBase.SetMetaData("Size", ((byte[])stream.GetBuffer()).Length);<---SAVED??  
                        contentBase.Content = new byte[0];  
                        contentBase.SetMetaData("Width", img.Width);  <<----SAVED VALUES but not used in Templates
                        contentBase.SetMetaData("Height", img.Height);  <<---SAVED VALUES but not used in templates
                          
                    }  
                }  
                else   
                {  
                    File.WriteAllBytes(GetFilePath(contentBase), contentBase.Content as byte[]);  
                    contentBase.Content = new byte[0];   
                }  
                base.SaveContent(contentBase as IContent, fireEvents);    
            } 
Register for webinar
3 posts, 0 answered