Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalide JSON in ashx connector; Initiate method #194

Closed
joeshmoe301 opened this issue Jun 8, 2017 · 10 comments
Closed

Invalide JSON in ashx connector; Initiate method #194

joeshmoe301 opened this issue Jun 8, 2017 · 10 comments
Labels
Milestone

Comments

@joeshmoe301
Copy link

The JSON generated by the initiate method in the ashx connector (https://github.com/servocoder/RichFilemanager/blob/master/connectors/ashx/filemanager.ashx) is invalid.

The issues are extra / missing commas.

Here is the updated code.

private string Initiate()
    {
        StringBuilder sb = new StringBuilder();
        sb.AppendLine("{");
        sb.AppendLine("\"id\": \"/\",");
        sb.AppendLine("\"type\": \"initiate\",");
        sb.AppendLine("\"attributes\": { \"config\": "); //]',

        sb.AppendLine("{");
        sb.AppendLine("\"options\": {");
        sb.AppendLine("	\"culture\": \"nl\",");
        sb.AppendLine("	\"charsLatinOnly\": false,");
        sb.AppendLine("	\"capabilities\": false,");
        sb.AppendLine("	\"allowFolderDownload\": false");
        sb.AppendLine("},");
        sb.AppendLine("\"security\": {");
        sb.AppendLine("	\"allowNoExtension\": false");
        sb.AppendLine("},");
        sb.AppendLine("\"upload\": {");
        sb.AppendLine("	\"fileSizeLimit\": 16000000,");
        sb.AppendLine("	\"policy\": \"ALLOW_ALL\"");
        //sb.AppendLine("	\"restrictions\": { \"jpg\" }");
        sb.AppendLine("}");
        sb.AppendLine("}");

        sb.AppendLine("}"); //config
        sb.AppendLine("}");

        return sb.ToString();
    }
@psolom
Copy link
Owner

psolom commented Jun 8, 2017

Thanks for the fix. ASHX connector was created in the end of 2016. Since that point a few major updated were rolled out, so ASHX connector may be outdated in some perspectives.

Feel free to create pull requests if you will found any other issues. Also it would be great if you decide to become a maintainer of ASHX connector and make it up to date with all latest features.

@psolom
Copy link
Owner

psolom commented Jun 8, 2017

Btw, you could create a new PR with the current fix and I will merge it.

@joeshmoe301
Copy link
Author

You are correct about the ashx connector being out of date in relation to the filemanager.js file. As I am working through trying to get it to work, I've found some other issues. At this point I am just testing this filemanager to see if I want to use it. I'm more interested in the .net mvc connector, but I think that one is even more out of date. I'll keep working on this for a bit to see if I can get it to work and then I'll get back with you.

I don't use github, so if I do get the connector working, i'll probably just post the code here and let you make the updates.

Thanks.

@psolom
Copy link
Owner

psolom commented Jun 8, 2017

Ok, hope you will like RFM.

No problem. I will roll out your code if you will make it to work.

@joeshmoe301
Copy link
Author

joeshmoe301 commented Jun 9, 2017

I think the only issue with the ashx connector was the Initiate method. It hadn't been updated. The code I used is below.

Two comments:

  1. I am having a difficult time restricting the filemanager to a specific folder (instead of the root folder). On this page (https://github.com/servocoder/RichFilemanager/wiki/How-to-open-%28exclusively%29-a-given-subfolder), there is a link called "how to setup dynamic user folder" (https://github.com/servocoder/RichFilemanager/wiki/Specify-user-folder%2C-configuration-cases). When I go to this page though, I don't see any information on how to do this. Do you have any suggestions for me? Is this something that hasn't been added to the code yet and needs to be done in the connector?

  2. On this page (https://github.com/servocoder/RichFilemanager/wiki/API), I think your Response example for "GET initiate" is incorrect. The JSON has "capabilities" and then a list of file extensions. I had to change that to "restrictions" to get the ashx handler to work. Maybe I am misunderstanding something though.

Thanks.

private string Initiate()
    {
        StringBuilder sb = new StringBuilder();
        sb.AppendLine("{");
        sb.Append("\"data\": {");
        sb.AppendLine("\"id\": \"/\",");
        sb.AppendLine("\"type\": \"initiate\",");
        sb.AppendLine("\"attributes\": {");
        sb.Append("\"config\": {");
        sb.AppendLine("\"security\": {");
        sb.AppendLine("\"readOnly\": false,");
        sb.AppendLine("\"extensions\": {");
        sb.AppendLine("\"policy\": \"ALLOW_LIST\",");
        sb.AppendLine("\"restrictions\": [\"jpg\",\"jpe\",\"jpeg\",\"gif\",\"png\"]");
        sb.AppendLine("}");
        sb.AppendLine("}");
        sb.AppendLine("}");
        sb.AppendLine("}");
        sb.AppendLine("}");
        sb.AppendLine("}");

        return sb.ToString();
    }

@psolom
Copy link
Owner

psolom commented Jun 9, 2017

ASHX connector doesn't support "extract" API method at least. Also there may be some issues in existing methods, but if they work for you it's cool!

  1. The first linked article is about how to "restrict" folder at the client side, but of course it's not reliable. If you interested in the server-side restriction it's completely connector-specific. The article that you was trying to reach was written for PHP connector exclusively, so I moved it to the appropriate repository. You can read it here. I can also point the exact lines of the implementation in the PHP connector, so you can use it as an example for your implementation if ASHX connector doesn't support this feature yet.

  2. Right. The API wiki article provides outdated response example. Thanks for pointing this, I will fix it.

@psolom
Copy link
Owner

psolom commented Jun 10, 2017

I have included your fix in the latest 2.5.0 release.
Let me know if you going to continue utilize ASHX connector.

@psolom psolom closed this as completed Jun 10, 2017
@psolom psolom added the bug label Jun 10, 2017
@psolom psolom added this to the 2.5.0 milestone Jun 11, 2017
@joeshmoe301
Copy link
Author

I actually switched to creating a .net mvc connector. I used the code from the .net core connector. I believe I almost have it completed. I'll give it to you when I am finished.

@psolom
Copy link
Owner

psolom commented Jun 12, 2017

Awesome!

Do you use this connector as a base?
There was another one ASP connector that I removed within the latest commit, since it was outdated.

Of course it's up to you which connector to use as a base.
I just want to make sure that you use the most actual connector as a base to not reinvent the wheel.

Looking forward your connector.

@joeshmoe301
Copy link
Author

I used the aspxnetcore, because that seemed to be more current. I had to make some changes, but it seems to be working for me. Do you have a way for me to contact you? I can send you the code and a bit of documentation on what I did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants