Unknown SeaweedFs Filer API response format

538 Views Asked by At

I've installed the last SeaweedFS version (version 30GB 1.72 linux amd64) using docker-compose, I'm running master, volume and filer servers.

All the system seems to work OK, I can upload and download files, however the API response when I query on a directory is different that the response showed in the official doc.

For instance, when I query the /dir1 directory with the command:

curl -H "accept: application/json" localhost:8888/dir1/?pretty=y

The response is like:

{
  "Path": "/dir1",
  "Entries": [
    {
      "FullPath": "/dir1/nyfile.bin",
      "Mtime": "2020-04-16T17:56:55Z",
      "Crtime": "2020-04-16T17:56:55Z",
      "Mode": 432,
      "Uid": 1000,
      "Gid": 1000,
      "Mime": "application/octet-stream",
      "Replication": "000",
      "Collection": "",
      "TtlSec": 0,
      "UserName": "",
      "GroupNames": null,
      "SymlinkTarget": "",
      "Md5": "zQnaPjjZsQpiU+N3RXp7GQ==",
      "Extended": null,
      "chunks": [
        {
          "file_id": "7,030d2d9790",
          "size": 55320265,
          "mtime": 1587059815546104803,
          "e_tag": "7b71a215",
          "fid": {
            "volume_id": 7,
            "file_key": 3,
            "cookie": 221091728
          }
        }
      ]
    }
  ],
  "Limit": 100,
  "LastFileName": "weed.bin",
  "ShouldDisplayLoadMore": false
}

That response is quite different from the example in the docs (https://github.com/chrislusf/seaweedfs/wiki/Filer-Server-API):

> curl -H "Accept: application/json" "http://localhost:8888/javascript/?pretty=y"            # list all files under /javascript/
{
  "Directory": "/javascript/",
  "Files": [
    {
      "name": "new_name.js",
      "fid": "3,034389657e"
    },
    {
      "name": "report.js",
      "fid": "7,0254f1f3fd"
    }
  ],
  "Subdirectories": null
}

So, I've got some questions:

  • Where is the documentation (if exists) for the new Filer REST API ?
  • How can I figure out what is a file and what is a directory with the new API ?
    • Currently, I'm using the "chunks" property, If there is "chunks" then It's a file otherwise is a directory.
  • How can I get the size of a file ? Should I sum the size property in all its chunks ?
1

There are 1 best solutions below

0
On BEST ANSWER
  • Documentation not there yet. The REST API is not used internally. Use gRPC for more advanced usages.
  • Mode follows os.Mode https://golang.org/pkg/os/#FileMode. Use os.ModeDir to determine file or directory.
  • Chunks may have overlaps. Use the highest watermark for file size.