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

Provide output in json #126

Closed
hacdias opened this issue Jul 18, 2017 · 4 comments
Closed

Provide output in json #126

hacdias opened this issue Jul 18, 2017 · 4 comments
Labels
enhancement ⚙ Improve an existing feature

Comments

@hacdias
Copy link
Member

hacdias commented Jul 18, 2017

From @dustinromey on August 7, 2016 21:35

Provide the file structure in json when the header "Accept: application/json" is included.

Copied from original issue: hacdias/filemanager-old#16

@hacdias hacdias added enhancement ⚙ Improve an existing feature on going labels Jul 18, 2017
@hacdias
Copy link
Member Author

hacdias commented Jul 18, 2017

The JSON output should be available in which pages? Browse only? Or do you want the content of a file too?

@hacdias
Copy link
Member Author

hacdias commented Jul 18, 2017

From @dustinromey on August 10, 2016 20:43

In my case its browse only.

My specific use case is the following: I have some files I want to sync to a mobile app. So the plan is to grab json showing the folders and files on the page, and then run through the json to grab the files that it does not currently have (or have been updated, etc.) In an ideal case, it could grab the entire directory tree in one http request. But having to step through folders is okay.

Its something I've been able to do with nginx with a couple of lines in nginx.conf. I'd like to do it in Caddy, and seems like it could be useful somewhat frequently. I'm assuming since it made it into the browse plugin, someone else found it useful too.

@hacdias
Copy link
Member Author

hacdias commented Jul 18, 2017

Hey @dustinromey! I just pushed with a probable "fix" for this. Try it and tell me if you think that the JSON should be formatted in other way. :D You've to build it from source.

@hacdias
Copy link
Member Author

hacdias commented Jul 18, 2017

From @dustinromey on August 18, 2016 20:21

Sorry it took so long. Had to figure out how to build with a plugin, so it took me a bit to get back to it.

The only thing I notice that seems strange is there's a number appended to the end of the json. For example, on a very simple test directory I got the following:
[ { "IsDir": true, "Name": "test", "Size": 170, "URL": "./test/", "Path": "", "RootPath": "", "ModTime": "2016-08-18T20:17:25Z", "Mode": 2147484141, "Mimetype": "", "Content": "", "Raw": null, "Type": "" }, { "IsDir": false, "Name": "hello.txt", "Size": 20, "URL": "./hello.txt", "Path": "", "RootPath": "", "ModTime": "2016-08-18T20:16:31Z", "Mode": 420, "Mimetype": "", "Content": "", "Raw": null, "Type": "" } ]544

Note the 544 at the end. What is that?

Otherwise looks great!

@hacdias hacdias closed this as completed Jul 18, 2017
@eine eine removed the on going label Jul 29, 2018
hacdias pushed a commit that referenced this issue May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ⚙ Improve an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants