DB Content Provider

2 posts, 0 answers
  1. Amarjyoti
    Amarjyoti avatar
    5 posts
    Member since:
    Aug 2010

    Posted 16 Aug 2010 Link to this post

    Dear Support,

    I am using the sample of the DBContentProvider to  make my application using FileExplorer.
    Only difference being that i am not saving the content of the file uploaded in the Database, I am using the FileSystem of the server to store the file physically.

    My approach is:

    1. I have kept a folder on the server file system (E.g. "C:\ClientFiles"). And i save all the uploaded file in that folder only just by changing the name of the File. The new name is the combination of the ID attribute of the File on the Database and its extension. E.g. If client is uploading an "Folder A\Folder Child\Apple.jpg" file, then i save it as "1.jpg" in the "C:\ClientFiles" folder. If client is uploading an "Folder B\Folder Child\Orange.jpg" file, then i save it as "2.jpg" in the "C:\ClientFiles" folder which is on the FileSystem in the server.

    Note: I am storing the Path of the File("C:\ClientFiles\1.jpg","C:\ClientFiles\2.jpg") and thier names ("Orange.jpg", "Apple.jpg") in the Database against their IDs.

    2.Now i have tried lots of things trying to show the preview of the file or download the file, but am not succeeding it. I know i need to make changes in the DBContentProvider class. Can you please tell me which all methods in the DBContentProvider class do i need to override to make it work.A sample would be great.
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 19 Aug 2010 Link to this post

    Hello Amarjyoti,

    Actually, you need to make changes the in the Generic Handler (Handler.ashx file), which serves the file to the browser, as well. The first thing that you need to change is to add a query string parameter to the FileItem's Url property. This should be done in the constructor of the FileItem. This is an example:
    FileItem newFileItem = new FileItem(name,
                        Path.GetExtension(name),
                            (int)childRow["Size"],
                        itemFullPath,
                        string.Format("{0}?id={1}", ItemHandlerPath, ItemID),
                        string.Empty,
                        GetPermissions(itemFullPath)
                        );

    Then you need to change the implementation of the Handler.ashx file in order to read the file from the local file system by using the passed id (in the query string), not from the DataBase.

    I hope this helps.

    Sincerely yours,
    Fiko
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top