We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Setting initial root folder dynamically for different users...

Thread ID:

Created:

Updated:

Platform:

Replies:

150683 Jan 16,2020 02:06 AM UTC May 19,2020 08:15 AM UTC Vue 3
loading
Tags: FileManager
jose luis barajas
Asked On January 16, 2020 02:09 AM UTC

Hi

I have the following code for my .net api (based in your samples)

  public class FileManagerController : ControllerBase
    {
        public PhysicalFileProvider operation;
        public string basePath;
        string root = "c:\\_paso\\test";

        public FileManagerController(IWebHostEnvironment hostingEnvironment)
        {
            // Map the path of the files to be accessed with the host
            this.basePath = hostingEnvironment.ContentRootPath;
            this.operation = new PhysicalFileProvider();
            // Assign the mapped path as root folder
            this.operation.RootFolder(this.root);
        }
...

I need to change the root directory according to the user's id
for example user id = 1 has folder name 0001, user id = 2 has folder name 0002 etc

I like to have
for user id = 1
root = "c:\\_paso\\test\0001";

user id = 2
root = "c:\\_paso\\test\0002";

etc

How can I pass the id from vue to the controller?

My declaration in vue its as follows
          <ejs-filemanager :ajaxSettings="ajaxSettings" :view="view" height="200" id="file-manager">ejs-filemanager>

In your samples I get this

But I dont understand...

Please help!!!



Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On January 17, 2020 12:03 PM UTC

Hi Jose, 
 
Thanks for contacting Syncfusion support. 
 
You can change the root directory based on the user id by using the beforeSend event of File Manager component. You can add the custom parameters in File Manager using this beforeSend event.  
 
Refer the below code block to add custom parameters. 
 
OnbeforeSend: function(args){ 
        var data = JSON.parse(args.ajaxSettings.data);  
     // Add custom parameter userid  
      data["userid"] = "1"; 
     // Add custom parameter in ajax settings  
      args.ajaxSettings.data = JSON.stringify(data);  
      } 
 
 
You can define the custom class along with custom parameter in controller part and use that new class in fileOperations.  
 
public class FileManagerDirectoryContent1 
    { 
        public FileManagerDirectoryContent[] Data { get; set; } 
        public bool ShowHiddenItems { get; set; } 
        public string SearchString { get; set; } 
        public bool CaseSensitive { get; set; } 
        public IList<IFormFile> UploadFiles { get; set; } 
        public string[] RenameFiles { get; set; } 
        public string TargetPath { get; set; } 
        public string ParentId { get; set; } 
        public string FilterId { get; set; } 
        public string FilterPath { get; set; } 
        public string Id { get; set; } 
        public string Type { get; set; } 
        public bool IsFile { get; set; } 
        public bool HasChild { get; set; } 
        public DateTime DateCreated { get; set; } 
        public DateTime DateModified { get; set; } 
        public string PreviousName { get; set; } 
        public long Size { get; set; } 
        public string Name { get; set; } 
        public string[] Names { get; set; } 
        public string NewName { get; set; } 
        public string Action { get; set; } 
        public string Path { get; set; } 
        public string userid { get; set; } 
        public FileManagerDirectoryContent TargetData { get; set; } 
        public AccessPermission Permission { get; set; } 
    } 
 
Refer the below screenshot, we can get the custom parameter value in event argument.  

 
 
We have prepared sample for your convenience kindly refer to the below link for the sample. 
 
 
Before running the above sample please extract the below file operation services and run it. 
 
 
In this above service, we have created a new class with custom parameter to showcase the demo sample of your requirement. 
 
Please let us know if you need any further assistance on this. 
 
Regards, 
Shameer Ali Baig S. 


jose luis barajas
Replied On January 17, 2020 08:48 PM UTC

Thanks for your support!!!
Its working now!!


Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On January 20, 2020 07:21 AM UTC

Hi Jose, 
  
We are pleased to hear that your problem is resolved. Please, get back to us if you need further assistance. 
  
Regards, 
Shameer Ali Baig S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon