This is a migrated thread and some comments may be shown as answers.

DB Content Provider

1 Answer 71 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Amarjyoti
Top achievements
Rank 1
Amarjyoti asked on 17 Aug 2010, 02:48 AM
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.

1 Answer, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 19 Aug 2010, 12:03 PM
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
Tags
FileExplorer
Asked by
Amarjyoti
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Share this question
or