I am curious, what is the first output with ‘Type: 0’ ?
I thought ‘/files/ls path’ should return a list of files and sub folders under the ‘path’ right ? why invalid.txt is returned with two different type values ?
The Type field is the type of object — e.g. a directory, a file, a symlink, etc. You can see a list here, where the protobuf format for UnixFS is defined: https://github.com/ipfs/go-ipfs/blob/master/unixfs/pb/unixfs.proto (unfortunately, UnixFS and these values aren’t formally documented anywhere).
why invalid.txt is returned with two different type values?
IPFS generally tries to always return the exact same format of data for a given command, regardless of the arguments. When you call files/ls without the l option, it only includes file names. All the other fields get left to their “unset” values (0 for numbers, “” for strings). If you add the l option, you should see all those fields filled in:
http://localhost:5001/api/v0/files/ls?arg=/&l
# or
http://localhost:5001/api/v0/files/ls?arg=/&l=true
Ah, sorry @canal, I got this wrong (as have, apparently, a whole bunch of other people). The UnixFS types (that you get with /ls) and MFS types (that you get with /files/ls are different). MFS uses 0 for files and 1 for directories.