You can append to any HTTP API with &pretty=y to see a formatted json output.
# Basic Usage:
//create or overwrite the file, the directories /path/to will be automatically created
POST /path/to/file
//get the file content
GET /path/to/file
//create or overwrite the file, the filename in the multipart request will be used
POST /path/to/
//return a json format subdirectory and files listing
GET /path/to/
Accept: application/json
# options for POST a file:
// set file TTL for Cassandra or Redis filer store.
POST /path/to/file?ttl=1d
// set file mode when creating or overwriting a file
POST /path/to/file?mode=0755
Examples:
# Basic Usage:
> curl -F [email protected] "http://localhost:8888/javascript/"
{"name":"report.js","size":866,"fid":"7,0254f1f3fd","url":"http://localhost:8081/7,0254f1f3fd"}
> curl "http://localhost:8888/javascript/report.js" # get the file content
...
> curl -F [email protected] "http://localhost:8888/javascript/new_name.js" # upload the file with a different name (The local report.js becomes new_name.js on the server side.)
{"name":"report.js","size":866,"fid":"3,034389657e","url":"http://localhost:8081/3,034389657e"}
> 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
}
This is for embedded filer only.
Some folder can be very large. To efficiently list files, we use a non-traditional way to iterate files. Every pagination you provide a "lastFileName", and a "limit=x". The filer locate the "lastFileName" in O(log(n)) time, and retrieve the next x files.
curl "http://localhost:8888/javascript/?pretty=y&lastFileName=new_name.js&limit=2"
{
"Directory": "/javascript/",
"Files": [
{
"name": "report.js",
"fid": "7,0254f1f3fd"
}
]
}
> curl -X DELETE http://localhost:8888/path/to/file
// recursively delete all files and folders under a path
> curl -X DELETE http://localhost:8888/path/to/dir?recursive=true
// recursively delete everything, ignoring any recursive error
> curl -X DELETE http://localhost:8888/path/to/dir?recursive=true&ignoreRecursiveError=true
// For Experts Only: remove filer directories only, without removing data chunks.
// see https://github.com/chrislusf/seaweedfs/pull/1153
> curl -X DELETE http://localhost:8888/path/to?recursive=true&skipChunkDeletion=true