Setting initial root folder dynamically for different users...
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!!!
SIGN IN To post a reply.
3 Replies
SA
Shameer Ali Baig Sulaiman Ali Baig
Syncfusion Team
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.
JL
jose luis barajas
January 17, 2020 08:48 PM UTC
Thanks for your support!!!
Its working now!!
SA
Shameer Ali Baig Sulaiman Ali Baig
Syncfusion Team
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.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
JL jose luis barajas
- Jan 16, 2020 02:06 AM UTC
- Jan 20, 2020 07:21 AM UTC