+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Libraries upload - save files to network path

Libraries upload - save files to network path

6 posts, 0 answered
  1. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    21 Jun 2011
    Link to this post
    Hi,

    You helped me previously with changing the libraries upload file path from the App_Data folder in this thread - http://www.sitefinity.com/devnet/forums/sitefinity-3-x/general-discussions/files-provider-upload-path.aspx

    I am now trying to modify it to upload to a network or UNC path (e.g. \\folder\Libraries) as we have the CMS load balanced and would like the files to be stored centrally on disk. My code works when the save location is set to a local path (e.g. D:\Content\Libraries) but not with a UNC path. I get an error when I upload a file saying "ProviderException: Value cannot be null. Parameter name: path".

    I can see that this is due to the way the FileUploadStream works (calling Path.GetDirectoryName(contentPath) with a UNC path seems to return null, and then Directory.Exists(path) throws an exception because path can't be null), however I have not been able to find a way to override the FileUploadStream.

    Can you please advise on whether there is a way I can override the FileUploadStream class as I have overridden the FileSystemProvider to save to a new location?
  2. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    21 Jun 2011
    Link to this post
    This is my file system provider:

    public class CustomFileSystemProvider : FileSystemProvider
        {
            private DefaultProvider Provider { get; set; }
     
            public CustomFileSystemProvider(DefaultProvider prov) : base(prov)
            {
                Provider = prov;
            }
             
            /// <summary>
            /// Base path of the file system provider. Defaults to ~/App_Data/Files/[Provider Application Name].
            /// </summary>
            /// <value></value>
            public override string BasePath
            {
                get
                {
                       // returns overridden path
                }
            }
    }

    Can I inherit from IStreamingContentProvider rather than FileSystemProvider, or does the LibrariesProvider require a provider of type FileSystemProvider?
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    21 Jun 2011
    Link to this post
    Hello Chris,

    You should inherit from FileSystemProvider. BasePath is a property implemented by FileSystemProvider not by the interface.

    Best wishes,
    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
  4. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    21 Jun 2011
    Link to this post
    This is what I've already done and have working for local file system paths, but it doesn't work for network paths for the reason I mentioned:

    "I can see that this is due to the way the FileUploadStream works (calling Path.GetDirectoryName(contentPath) with a UNC path seems to return null, and then Directory.Exists(path) throws an exception because path can't be null)"

  5. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    22 Jun 2011
    Link to this post
    I have managed to implement a new IStreamingLibrariesProvider for the libraries module which will accept a network path. I found an example elsewhere on the forums - http://www.sitefinity.com/devnet/forums/sitefinity-3-x/developing-with-sitefinity/can-i-develop-my-own-streamingprovider.aspx

    And I have basically copied the code from FileDownloadStream and FileUploadStream and removed the code that was causing problems.

    Thanks.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    24 Jun 2011
    Link to this post
    Hi Chris,

    Thanks for the update in community forum. I am glad to here that you managed to sort out the issue. Hope this will help to others as well.

    Best wishes,
    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
Register for webinar
6 posts, 0 answered