1
How to disable download/print and only allow preview in FileManager?
Question asked by azure - 11/23/2020 at 6:28 AM
Answered
After I set the permission as below, preview button is disabled. Any idea? My goal is to only allow preview and disabled download and print. Looks like Preview is depended on Download permission.
                acl.AllowedPermissions = FileManagerPermissions.Extract | FileManagerPermissions.ListFiles | FileManagerPermissions.ListSubfolders | FileManagerPermissions.Preview | FileManagerPermissions.ReadOnly;
                acl.DeniedPermissions = FileManagerPermissions.Download | FileManagerPermissions.Copy | FileManagerPermissions.Print;

6 Replies

Reply to Thread
0
Cem Alacayir Replied
Employee Post
First of all, from the docs:

Public propertyAllowedPermissionsGets or sets the permission types that are allowed.
Permission types are ListSubfolders, ListFiles,
 Create, Delete, Rename, Edit, Upload, Download,
 Compress, Extract, Cut, Copy, Paste, Preview,
 Print and Full (includes all permissions)
and ReadOnly (includes only ListSubfolders,
ListFiles, Download, Copy). When combining
 permissions, they should be separated by comma.
 If omitted, all permissions will be considered
 denied.

Public propertyDeniedPermissionsGets or sets the permission types that are denied.
Denied permissions take precedence over
allowed permissions. For instance,
when AllowedPermissions
 is set to Full and DeniedPermissions is set to
Upload, Download, all permission except Upload
and Download will be allowed.

So it's easier to allow all permissions and then only disallow specific permissions you want, like this:

acl.AllowedPermissions = FileManagerPermissions.Full;

acl.DeniedPermissions = FileManagerPermissions.Download | FileManagerPermissions.Copy | FileManagerPermissions.Print;
or like this:

acl.AllowedPermissions = FileManagerPermissions.ReadOnly;

acl.DeniedPermissions = FileManagerPermissions.Download | FileManagerPermissions.Copy | FileManagerPermissions.Print;
By the way ReadOnly means this already:

        ReadOnly = ListSubfolders
            | ListFiles
            | Download
            | Copy
            | Preview
            | Print,

Also note that Preview button will be disabled for a file if it's not supported by DocumentViewer, ImageViewer or MediaPayer.
0
azure Replied
Hi Cem,
The problem is that denying download permission and allowing preview don't play together. At least in my test with the latest version of fileultimate. I have to allowing download permission to get preview permission work but that's not I want. I am testing with PDF file so that's not a problem of the file type. So I wonder if it's a bug or I am missing something. 
0
Cem Alacayir Replied
Employee Post
No, Preview permission does not depend on Download permission.
I tested your code like this and it works:

rootFolder.AccessControls.Add(new FileManagerAccessControl
{
    Path = @"\",
    AllowedPermissions = FileManagerPermissions.Extract | FileManagerPermissions.ListFiles | FileManagerPermissions.ListSubfolders | FileManagerPermissions.Preview | FileManagerPermissions.ReadOnly,
    DeniedPermissions = FileManagerPermissions.Download | FileManagerPermissions.Copy | FileManagerPermissions.Print
});
Maybe you are not adding the correct FileManagerAccessControl instance or you are not considering the inheritance? I need to see your whole code.
0
azure Replied
I am using the webform version of the FileManagerControl, don't know if that makes a difference.
The code behide is like below:

                 RootF.Location = @"c:\Myfolder";

var acl = new FileManagerAccessControl();
            acl.Path = @"\";
                            acl.AllowedPermissions = FileManagerPermissions.Extract | FileManagerPermissions.ListFiles | FileManagerPermissions.ListSubfolders | FileManagerPermissions.Preview | FileManagerPermissions.ReadOnly;
                acl.DeniedPermissions = FileManagerPermissions.Download | FileManagerPermissions.Copy | FileManagerPermissions.Print;
RootF.Name = "Myfolder';

            RootF.AccessControls.Add(acl);
            fileManager.RootFolders.Add(RootF);
0
Cem Alacayir Replied
Employee Post Marked As Answer
There was a syntax error in your code, it was not even compiling (there was ' instead of " in the highlighted place):

var RootF = new FileManagerRootFolder();
RootF.Location = @"c:\Myfolder";

var acl = new FileManagerAccessControl();
acl.Path = @"\";
acl.AllowedPermissions = FileManagerPermissions.Extract | FileManagerPermissions.ListFiles | FileManagerPermissions.ListSubfolders | FileManagerPermissions.Preview | FileManagerPermissions.ReadOnly;
acl.DeniedPermissions = FileManagerPermissions.Download | FileManagerPermissions.Copy | FileManagerPermissions.Print;
RootF.Name = "Myfolder";

RootF.AccessControls.Add(acl);
fileManager.RootFolders.Add(RootF);
And after this fix, this code works as expected?

You said before:
> Yes I was using an old version. 

Are you sure you updated to the latest properly? The DLLs in your bin folder should be these versions (they come as a set):

GleamTech.FileUltimate 7.8.1
GleamTech.Common 4.4.1
GleamTech.ImageUltimate 4.4.1
GleamTech.VideoUltimate 2.5.1
GleamTech.DocumentUltimate 5.8.1

Ensure there is no old DLL file named GleamTech.Core.dll anywhere in your project, it was replaced with new DLL file named GleamTech.Common.dll since Version 7.3.0 - November 20, 2019 

In Visual Studio: Go to Tools -> NuGet Package Manager -> Package Manager Console and run these commands one by one in order: 

Uninstall-Package FileUltimate -RemoveDependencies 
Uninstall-Package FileUltimate.NuGetOrg -RemoveDependencies 
Install-Package GleamTech.FileUltimate

If you are using direct DLL references instead of NuGet reference, first clean your project, remove references to old assembly GleamTech.Core.dll, add references to new assembly and rebuild your project. Ensure there is no GleamTech.Core.dll left in your project bin folders.


0
azure Replied
Problem is solved after I upgraded to FileUltimate 7.8.1 from 7.8.0.
Thank you.

Reply to Thread