gordon-matt / peachpie-responsive-file-manager

Responsive File Manager running on .NET Core with Peachpie
24 stars 16 forks source link

Tenant not working #13

Closed minhvan closed 3 years ago

minhvan commented 4 years ago

In the Standalone example, I see tenant "Tenant_1" in rootFolder parameter:

But it does not work, still pointing to "/Media/Uploads" How can I change to "/Tenant_1/Media/Uploads" or "/Media/Uploads/Tenant_1"? Thank you Gordon.

gordon-matt commented 4 years ago

Thank you for noticing this. It seems that somehow my code for that was overwritten. Anyway, I have added it back here: https://github.com/gordon-matt/peachpie-responsive-file-manager/commit/02fe23bb5065396368e0cac7aac766d28abeb878. But, there still seems to be a bug and I think it's PeachPie.

@jakubmisek : FYI - This issue we are discussing here is with regards to a new parameter I added to the RFM's dialog.php so we can restrict user access to a specific folder... if you open Standalone.cshtml and look at the <iframe>, you will see a "rootFolder" parameter there, along with some other parameters.

Now if you go to IFrame.cshtml, you will see another <iframe>, but with only 1 parameter (type=0).

If you run the demo, go to IFrame.cshtml first and see it's working correctly.. you should not be restricted... Then go to Standalone.cshtml and it will also work correctly... you will be restricted to the Tenant_1 subfolder (assuming you have created that folder (\Media\Uploads\Tenant_1). Finally, go back to IFrame.cshtml again and this time you will see it is now restricted to the subfolder just like in the standalone page.

So I think the parameters are being cached or something.. I might be wrong here, but I am sure it didn't used to be like this before.

Can you give me some advice here? The parameters should not be cached between pages.

PS - Use the "develop" branch

jakubmisek commented 4 years ago

@gordon-matt from https://github.com/gordon-matt/peachpie-responsive-file-manager/commit/02fe23bb5065396368e0cac7aac766d28abeb878 it seems you add a session variable, but it is not cleared when subfolder is not specified. I'll try it soon, but my first thought is, the $_SESSION['RF']["subfolder"] is persisted in the session.

gordon-matt commented 3 years ago

@jakubmisek Any further thoughts on this issue?

minhvan commented 3 years ago

Thank you @gordon-matt, My solution is configuring the middleware in startup.cs Every request to ResponsiveFileManager will call 'BeforeRequest' event. So I config the tenant folder here.

        app.UsePhp(new PhpRequestOptions(scriptAssemblyName: "ResponsiveFileManager")
        {
            BeforeRequest = (Context ctx) =>
            {
                ctx.Globals["appsettings"] = new PhpArray
                {
                    { "upload_dir", uploadDir }, // change the tenant folder
                    { "current_path", curPath },
                    { "thumbs_base_path", thumbsPath },
                    { "MaxSizeUpload", rfmOptions.MaxSizeUpload } 
                };
            }
        });

Another question, how can I upload non-image documents? Like pdf, docx, xlsx,.... Currently it throw an exception when I try to upload pdf files.

gordon-matt commented 3 years ago

Could you paste the exception message? Because I just tried the demo and it works fine. I was able to upload .pdf and .docx files without any errors.

gordon-matt commented 3 years ago

@minhvan I will close this issues, since you have a solution. As for the error with uploading pdf and docx files, you can open a new issue, if you are still having problems

minhvan commented 3 years ago

I upgrade to your latest version and it works. Thank you