GET $URL?t=json
- out: json metadata
+ out: json description of $URL
This returns machine-parseable information about the indicated file or
directory in the HTTP response body. The JSON always contains a list, and
If it is a file, then the information includes file size and URI, like
this:
- [ 'filenode', { 'ro_uri': file_uri,
- 'size': bytes } ]
+ GET $FILEURL?t=json :
+
+ [ 'filenode', { 'ro_uri': file_uri,
+ 'size': bytes,
+ 'metadata': {'ctime': 1202777696.7564139,
+ 'mtime': 1202777696.7564139,
+ },
+ } ]
If it is a directory, then it includes information about the children of
- this directory, as a mapping from child name to a set of metadata about the
+ this directory, as a mapping from child name to a set of data about the
child (the same data that would appear in a corresponding GET?t=json of the
- child itself). Like this:
-
- [ 'dirnode', { 'rw_uri': read_write_uri,
- 'ro_uri': read_only_uri,
- 'children': children } ]
-
- In the above example, 'children' is a dictionary in which the keys are
- child names and the values depend upon whether the child is a file or a
- directory:
-
- 'foo.txt': [ 'filenode', { 'ro_uri': uri, 'size': bytes } ]
- 'subdir': [ 'dirnode', { 'rw_uri': rwuri, 'ro_uri': rouri } ]
+ child itself). The child entries also include metadata about each child,
+ including creation- and modification- timestamps. The output looks like
+ this:
- note that the value is the same as the JSON representation of the child
- object (except that directories do not recurse -- the "children" entry of
- the child is omitted).
+ GET $DIRURL?t=json :
+
+ [ 'dirnode', { 'rw_uri': read_write_uri,
+ 'ro_uri': read_only_uri,
+ 'children': [
+ 'foo.txt': [ 'filenode', { 'ro_uri': uri,
+ 'size': bytes,
+ 'metadata': {
+ 'ctime': 1202777696.7564139,
+ 'mtime': 1202777696.7564139,
+ },
+ } ],
+ 'subdir': [ 'dirnode', { 'rw_uri': rwuri,
+ 'ro_uri': rouri,
+ 'metadata': {
+ 'ctime': 1202778102.7589991,
+ 'mtime': 1202778111.2160511,
+ },
+ } ],
+ ] } ]
+
+ In the above example, note how 'children' is a dictionary in which the keys
+ are child names and the values depend upon whether the child is a file or a
+ directory. The value is mostly the same as the JSON representation of the
+ child object (except that directories do not recurse -- the "children"
+ entry of the child is omitted, and the directory view includes the metadata
+ that is stored on the directory edge).
Then the rw_uri field will be present in the information about a directory
if and only if you have read-write access to that directory,
self.BAR_CONTENTS, n, self._bar_txt_uri = self.makefile(0)
foo.set_uri("bar.txt", self._bar_txt_uri)
+
foo.set_uri("empty", res[3][1].get_uri())
sub_uri = res[4][1].get_uri()
foo.set_uri("sub", sub_uri)
# public/reedownlee/
# public/reedownlee/nor
self.NEWFILE_CONTENTS = "newfile contents\n"
+
+ return foo.get_metadata_for("bar.txt")
d.addCallback(_then)
+ def _got_metadata(metadata):
+ self._bar_txt_metadata = metadata
+ d.addCallback(_got_metadata)
return d
def makefile(self, number):
["bar.txt", "blockingfile", "empty", "sub"])
kids = data[1]["children"]
self.failUnlessEqual(kids["sub"][0], "dirnode")
+ self.failUnless("metadata" in kids["sub"][1])
+ self.failUnless("ctime" in kids["sub"][1]["metadata"])
+ self.failUnless("mtime" in kids["sub"][1]["metadata"])
self.failUnlessEqual(kids["bar.txt"][0], "filenode")
self.failUnlessEqual(kids["bar.txt"][1]["size"], len(self.BAR_CONTENTS))
self.failUnlessEqual(kids["bar.txt"][1]["ro_uri"], self._bar_txt_uri)
+ self.failUnlessEqual(kids["bar.txt"][1]["metadata"]["ctime"],
+ self._bar_txt_metadata["ctime"])
def GET(self, urlpath, followRedirect=False):
url = self.webish_url + urlpath