You can append to any HTTP API with &pretty=y to see a formatted json output.

Filer server

POST/PUT/Get files

  1. # Basic Usage:
  2. //create or overwrite the file, the directories /path/to will be automatically created
  3. POST /path/to/file
  4. //get the file content
  5. GET /path/to/file
  6. //create or overwrite the file, the filename in the multipart request will be used
  7. POST /path/to/
  8. //return a json format subdirectory and files listing
  9. GET /path/to/
  10. Accept: application/json
  11.  
  12. # options for POST a file:
  13. // set file TTL for Cassandra or Redis filer store.
  14. POST /path/to/file?ttl=1d
  15. // set file mode when creating or overwriting a file
  16. POST /path/to/file?mode=0755

Examples:

  1. # Basic Usage:
  2. > curl -F file=@report.js "http://localhost:8888/javascript/"
  3. {"name":"report.js","size":866,"fid":"7,0254f1f3fd","url":"http://localhost:8081/7,0254f1f3fd"}
  4. > curl "http://localhost:8888/javascript/report.js" # get the file content
  5. ...
  6. > curl -F file=@report.js "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.)
  7. {"name":"report.js","size":866,"fid":"3,034389657e","url":"http://localhost:8081/3,034389657e"}
  8. > curl -H "Accept: application/json" "http://localhost:8888/javascript/?pretty=y" # list all files under /javascript/
  9. {
  10. "Directory": "/javascript/",
  11. "Files": [
  12. {
  13. "name": "new_name.js",
  14. "fid": "3,034389657e"
  15. },
  16. {
  17. "name": "report.js",
  18. "fid": "7,0254f1f3fd"
  19. }
  20. ],
  21. "Subdirectories": null
  22. }

List files under a directory

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.

  1. curl "http://localhost:8888/javascript/?pretty=y&lastFileName=new_name.js&limit=2"
  2. {
  3. "Directory": "/javascript/",
  4. "Files": [
  5. {
  6. "name": "report.js",
  7. "fid": "7,0254f1f3fd"
  8. }
  9. ]
  10. }

Deletion

Delete a file

  1. > curl -X DELETE http://localhost:8888/path/to/file

Delete a folder

  1. // recursively delete all files and folders under a path
  2. > curl -X DELETE http://localhost:8888/path/to/dir?recursive=true
  3. // recursively delete everything, ignoring any recursive error
  4. > curl -X DELETE http://localhost:8888/path/to/dir?recursive=true&ignoreRecursiveError=true
  5.  
  6. // For Experts Only: remove filer directories only, without removing data chunks.
  7. // see https://github.com/chrislusf/seaweedfs/pull/1153
  8. > curl -X DELETE http://localhost:8888/path/to?recursive=true&skipChunkDeletion=true