Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>[...the preferred way of implementing cp would include GETting the resource, DELETing it and PUTting it back again with a new name.]</p> </blockquote> <p>One problem with the above approach is lack of atomicity and consistency. Since each of the operations (GET, DELETE and PUT) happen over HTTP (which is stateless inherently) the server cannot enforce atomicity. For any reason, the client may abort after any step before the last step and that would leave the server with an inconsistent state in terms of its data.</p> <p><strong>A possible approach:</strong></p> <ul> <li>If the resources are documents (which I guess, they are in your case) I'd explore the option of using <a href="http://en.wikipedia.org/wiki/WebDAV" rel="nofollow noreferrer">WebDAV</a>.</li> <li>If WebDAV is not an option -- <ul> <li>create a controller object on the server to manage copy and move operations, client can POST to something like /videos/my_videos/[video_id]/copy</li> <li>In your response you can specify the URI to the copied resource, in the lines of:</li> </ul></li> </ul> <blockquote> <p>HTTP/1.1 201 Created</p> <p>Content-type:video/x-msvideo </p> <p>Location:/videos/johns_videos/8765</p> </blockquote> <p><strong>Note:</strong> I prefer sending an ID back and working with resource IDs rather than something like </p> <blockquote> <p>Location: /videos/johns_videos/copied-2-gigabyte-video.avi</p> </blockquote> <p>Move operation is pretty similar except that the server may accept a destination resource. Example:</p> <blockquote> <p><a href="http://example.com//videos/johns_videos/8765/move?destination=[destination]" rel="nofollow noreferrer">http://example.com//videos/johns_videos/8765/move?destination=[destination]</a></p> </blockquote> <p>You can extend the above approach such that the server sends a Last-Modified tag to the client and client sends that along with its request. The server will perform the copy/move operations only when that value is still consistent. This will address concurrency issues with the resource being changed while your copy/move operations are still in progress. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload