There are obvious counterparts for some of file systems\' basic operations (eg. ls
and rm
), but how would you implement not straightforwardly RESTf
I dont believe any of the given answers are RESTful. Here is what I would do.
For Copy:
PUT /videos/johns_videos/copied-2-gigabyte-video.avi
HOST: www.server.com
Content-Location: /videos/johns_videos/2-gigabyte-video.avi
[empty-body]
PUT the content's at location (/videos/johns_videos/2-gigabyte-video.avi) at (/videos/johns_videos/copied-2-gigabyte-video.avi).
A move would be a copy with a delete, to check for consistency between the copy and delete you will need to use a revision number which is given to you on the response of the PUT.
PUT /videos/johns_videos/copied-2-gigabyte-video.avi
HOST: www.server.com
Content-Location: /videos/johns_videos/2-gigabyte-video.avi
[empty-body]
201 Created
ETag: "3e32f5a1123afb12" (an md5 of the file)
Location: /videos/johns_videos/copied-2-gigabyte-video.avi
[empty-body]
DELETE /videos/johns_videos/2-gigabyte-video.avi
HOST: www.server.com
If-Match: "3e32f5a1123afb12"
[empty-body]
204 No Content
[empty-body]
Why is this RESTful?
Mike Brown