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

allow returning file details in JSON #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adamarthurryan
Copy link

I'm proposing a patch that allows fs.Stats file info to be returned in JSON. This is be enabled by the jsonStat option. The stat fields properties are screened to only pass a machine-neutral subset (ie. not exposing user ids, device ids, etc.). Also, the isFile() and isDirectory() function return values are encoded as properties.

Any thoughts on this?

@adamarthurryan
Copy link
Author

I'm not sure that the selection of properties returned is quite right. Perhaps it would make sense to depart from the fs.Stats format and come up with a better list of relevant properties. (Eg. type=[file|dir], readable, writable, created, modified, etc.)

@adamarthurryan
Copy link
Author

Ah, also, I guess I used some too-newfangled JS in my testing code. I'll revise that.

@dougwilson dougwilson self-assigned this Jan 15, 2016
@dougwilson dougwilson added the pr label Jan 15, 2016
@dougwilson
Copy link
Contributor

I like this idea, sorry this repo has been on the side lines for a while. Any interest in rebasing it to the latest master / making the JS change you mentioned?

@coolaj86
Copy link

I’ve also created a PR for this.

#74

My implementation is slightly different in that it adheres to the W3 File API:

  • name
  • size
  • type
  • lastModified

Type is “inode/directory” for dirs.

With my string of commits the goal is to provide the same subset of data to all of the serveIndex template functions (plain, json, html) and pave a way forward for separating the security and functionality from the view and layout so that it’s easy to publish and use a “theme” module to handle diverse needs rather than having to fork serve-index itself and potentially fall behind.

Does that work for your use case? Or do you specifically need access time and the date of creation?

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

Successfully merging this pull request may close these issues.

3 participants