FileManager 18.4.35 Prevent Upload and User Delete

Hi There,

Could you provide a Blazor sample using version 18.4.35 where the filemanager only provides the following functionality:

Requirements 
     - Download only functionality (we have an admin user that can upload content that is to be consumed by a different role in the app)
     - Prevent User from deleting files 
     - Prevent user from deleting files using the delete key on keyboard
     - Prevent Dragging files onto filemanager for upload (DOWNLOAD ONLY)
     - Remove text that says "Drag files here to upload"
     - Permission control based on role or userid (AspNetIdentity)


1 Reply 1 reply marked as answer

SP Sowmiya Padmanaban Syncfusion Team January 25, 2021 04:03 PM UTC

Hi Andrew Renner, 
 
Greetings from Syncfusion support. 
 
We have checked your requirement with FileManager component.  We have provided access control support for FileManager component similar to your requirement.  
 
Query 1-  Permission control based on role or userid (AspNetIdentity) && Prevent User from deleting files  && Prevent user from deleting files using the delete key on keyboard 
 
You can set the permission based on user id. You need to send the user id through onSend event. 
 
Please, refer to the below code snippet. 
 
@using Syncfusion.Blazor.FileManager 
<div class="control-section"> 
    <SfFileManager TValue="FileManagerDirectoryContent"> 
        <FileManagerEvents TValue="FileManagerDirectoryContent" OnSend="send" ></FileManagerEvents> 
        <FileManagerAjaxSettings Url="/api/Home/FileOperations" 
                                 UploadUrl="/api/Home/Upload" 
                                 DownloadUrl="/api/Home/Download" 
                                 GetImageUrl="/api/Home/GetImage"> 
        </FileManagerAjaxSettings> 
    </SfFileManager> 
</div> 
 
@code { 
    SfFileManager<FileManagerDirectoryContent> filemanager; 
    public void send(Syncfusion.Blazor.FileManager.BeforeSendEventArgs args) 
    { 
        Dictionary<string, object> data = new Dictionary<string, object>(); 
        data.Add("User_name", "user1"); 
        args.CustomData = data; 
    } 
} 
  public class FileManagerDirectoryContent1 
    { 
        public Dictionary<string, object> CustomData { get; set; } 
        public FileManagerDirectoryContent[] Data { get; set; } 
        public bool ShowHiddenItems { get; set; } 
        public string SearchString { get; set; } 
    } 
[Route("FileOperations")] 
        public object FileOperations([FromBody] FileManagerDirectoryContent1 args) 
        { 
            username = args.CustomData["User_name"].ToString(); 
            this.operation.SetRules(GetRules(username)); 
} 
public AccessDetails GetRules(string user_value) 
        { 
            AccessDetails accessDetails = new AccessDetails(); 
 
            List<AccessRule> accessRules = new List<AccessRule> {   
                // For Default User            
                 new AccessRule { Path = "/*.*", Role = "Adminstrator", Read = Permission.Allow, Write = Permission.Deny, Copy = Permission.Deny, WriteContents = Permission.Deny, Upload = Permission.Deny, Download = Permission.Deny}, 
                  new AccessRule { Path = "/*.*", Role = "Adminstrator", Read = Permission.Allow, Write = Permission.Deny, Copy = Permission.Deny, WriteContents = Permission.Deny, Upload = Permission.Deny, Download = Permission.Deny, IsFile=true}, 
            }; 
            accessDetails.AccessRules = accessRules; 
            if (user_value == "user1") 
            { 
                // Here, you need to set the role for FileManager component. 
                accessDetails.Role = "Adminstrator"; 
            } 
            else 
            { 
                accessDetails.Role = "Document Manager"; 
            } 
            return accessDetails; 
        } 
 
Please, refer the below link for access control in FileManager component. 
 
 
When you set the write attribute as deny, it prevents the editing of files/folders in FileManager component ( rename, delete, create folder). 
 
Query 2- Prevent Dragging files onto FileManager for upload (DOWNLOAD ONLY) 
 
When you set upload as deny, it does not upload the files in the corresponding path. But, we are facing some issue in FileManager component . We have considered your reported issue as bug in FileManager component. We will include the fix for this bug in our third patch release after Volume 1 release which is expected to be rolled out by the end of March 2021. 
 
You can track the status of this issue through the following feedback portal link.   
 
 
We appreciate your patience. 
 
Query 3- Remove text that says "Drag files here to upload 
 
You can remove the text by using localization property of FileManager component. Please, refer the below documentation link for more details on localization property. 
 
 
We suggest you to empty the FileManager_FileUpload Value as empty in SFResources.resx file in Resources folder. 
 
 
 
We have attached a sample for reference in the following link 
 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 


Marked as answer
Loader.
Up arrow icon