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

RadFileExplorer upload issue and how to setup for use with multiple users?

1 Answer 213 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Nimesh
Top achievements
Rank 1
Nimesh asked on 17 May 2011, 12:40 AM
Having a issue with getting the RadFileExplorer work with the example provided in
http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/server-sideapi/dbfilebrowsercontentprovider/defaultcs.aspx

Following is the code used in my aspx file

<telerik:RadFileExplorer runat="server" ID="RadFileExplorer1" Width="750px" Height="500px"
OnClientItemSelected="OnClientItemSelected"
            Skin="Sitefinity">
<Configuration ViewPaths="~/Root/Default/ViewPath" UploadPaths="~/Root/Default/UploadPath"
   DeletePaths="~/Root/Default/DeletePath"  />
</telerik:RadFileExplorer> I have the ViewPaths, UploadPaths and DeletePaths set up in my solution as in the attached file (fileupload.png). The table structure is modeled according to the Items table with the addition of column CreatedBy. Have the following record in the Items table ItemID:1 Name: Root ParentID: NULL MimeType: NULL IsDirectory: True Size: NULL Content: NULL upsize_ts: NULL CreatedBy: nmarker Question 1: With the above setup I am unable to upload documents, or create Directories. Check file screenshot2.png My requirement is every logged in user to my website will have their own file structure defined in the DB. Have modified DataServer.cs
 private DataTable Data
    {
...                 SqlDataAdapter adapter = new SqlDataAdapter("SELECT ItemID, [Name], ParentID, MimeType, IsDirectory, [Size]FROM rbItems where CreatedBy='" + clsUtility.getLoggedInUserName() + "' ORDER BY ItemID", Connection);
        ...
    }
public byte[] GetContent(string path)
    {
..         SqlCommand command = new SqlCommand("SELECT Content FROM rbItems WHERE ItemID = @ItemID AND CreatedBy = @CreatedBy", Connection);
        ...
    }

    public void CreateItem(string name, string path, string mimeType, bool isDirectory, long size, byte[] content)
    {
..         SqlCommand command =
            new SqlCommand(
                "INSERT INTO rbItems ([Name], ParentId, MimeType, IsDirectory, [Size], Content, CreatedBy) VALUES (@Name, @ParentId, @MimeType, @IsDirectory, @Size, @Content, @CreatedBy)", Connection);
        ...
        command.Parameters.Add(new SqlParameter("@CreatedBy"clsUtility.getLoggedInUserName()));
...     }
Question 2: Can all logged in users share the same physical folder structure? as in fileupload.png? or should each user have their own folder structure defined? Please advise.

1 Answer, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 19 May 2011, 04:44 PM
Hi Nimesh,

Straight to your questions:

1) I downloaded the project from the http://www.telerik.com/community/code-library/aspnet-ajax/file-explorer/connect-radfileexplorer-or-radeditor-to-a-sql-databse.aspx and modified it to resemble your scenario. Basically here is what I did:
  • Added another column to the Items table, of type nvarchar(50).
  • Modified the 3 methods you have modified.
  • For the UserName I use a static string
However, everything worked as expected. No errors where thrown, and I could easily perform any action (like create new folders, upload and delete files) with the FileExplorer. You can find my sample project attached to the thread. Due to its large size, it was archived with rar compression and you can extract it using the free 7-Zip or the trial WinRar tool.
Please make sure the SQL Queries return the correct data.
One thing I noticed in the provided record is, you have NULL upsize_ts field, which does not allow nulls. Please make sure this field is always populated.

2) Each user should have its own folder, because if two users use one and the same folder, one of the users might delete the files of the other and vice-versa.

Greetings,
Pero
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
FileExplorer
Asked by
Nimesh
Top achievements
Rank 1
Answers by
Pero
Telerik team
Share this question
or