1

I want to develop a REST server file manager with resume capability using .Net Core WebApi. Currently I have:

GET api/FileManager/path/to/directory: returns JSON with the content of the directory (subdirectories and files)

GET api/FileManager/path/to/file.txt: download the file with resume capability (e.g. Range: Bytes=0-1023)

HEAD api/FileManager/path/to/file/or/directory: returns empty 200 if the file or directory exists, if not returns empty 404

PUT api/FileManager/path/to/file.txt (with the file content in the body): upload a file

DELETE: delete a file or directory if it exists

Now I am struggling with other functions such as rename or compress My questions:

  1. How can I implement "rename" (which includes the Move case) a file or directory function with REST? Is it PUT or PATCH? I am thinking that the input would have to contain the new full name of the file/directory
  2. How can I implement "compress"? The client will send a JSON body containing the files and directories to be added to the ZIP file. None of the VERBS sounds suitable, for example, if I use POST, will not be able to differentiate with the file upload
  3. Am I missing anything in implementing file download with resume? I heard about bytes=0-0,-1 but have no idea about it.
  • You should use PUT to create a file if you're specifying the URL under which it should be available. POST is for when you want an item created, but do not know what it's final URL should be. See [PUT vs POST in REST](http://stackoverflow.com/questions/630453/put-vs-post-in-rest) – kicken Jun 11 '16 at 05:06
  • Makes sense! I updated the original question. – Nguyễn Việt Trung Jun 11 '16 at 07:31

0 Answers0