Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 807703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:26:38+00:00 2026-05-15T00:26:38+00:00

There are obvious counterparts for some of file systems’ basic operations (eg. ls and

  • 0

There are obvious counterparts for some of file systems’ basic operations (eg. ls and rm), but how would you implement not straightforwardly RESTful actions such as cp or mv?

As answers to the question How to implement copy paste of a resource in REST? suggest, the preferred way of implementing cp would include GETting the resource, DELETing it and PUTting it back again with a new name.

But what if I would need to do it efficiently? For instance, if the resource’s size would be huge? How would I eliminate the superfluous transmission of resource’s payload to client and back to the originating server?

Here is an illustration. I have a resource:

/videos/my_videos/2-gigabyte-video.avi

and I want copy it into a new resource:

/videos/johns_videos/copied-2-gigabyte-video.avi

How would I implement the copy, move or other file system actions the RESTful way? Or is there even a proper way? Am I doing it all wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:26:39+00:00Added an answer on May 15, 2026 at 12:26 am

    […the preferred way of implementing
    cp would include GETting the resource,
    DELETing it and PUTting it back again
    with a new name.]

    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.

    A possible approach:

    • If the resources are documents (which I guess, they are in your case) I’d explore the option of using WebDAV.
    • If WebDAV is not an option —
      • 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
      • In your response you can specify the URI to the copied resource, in the lines of:

    HTTP/1.1 201 Created

    Content-type:video/x-msvideo

    Location:/videos/johns_videos/8765

    Note: I prefer sending an ID back and working with resource IDs rather than something like

    Location:
    /videos/johns_videos/copied-2-gigabyte-video.avi

    Move operation is pretty similar except that the server may accept a destination resource. Example:

    http://example.com//videos/johns_videos/8765/move?destination=%5Bdestination%5D

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there some standards that you consider to be so obvious that they would
Trying to follow this example. (Section String sorting...) Is there anything obvious that would
I'm trying to use Zlib::Deflate.deflate on a massive file (4 gigs). There are obvious
There are the obvious quirks of Math.Round but is there a way to make
I'm sure there's something obvious I'm missing here, but I know that popover controls
Is there some obvious method for dealing with DataTemplates of which I am unaware?
I am implementing a simple license-file system, and would like to know if there
Is there some obvious way to add a separator to the list of options
Is there a way to make an element not contribute to parent overflow, but
I do most of my development in Common Lisp, but there are some moments

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.