title: How to preserve the timestamp of an io.Reader when copying a file by using a REST service in go?
body: <p>I am writing some microservices in Go which handle different files. </p>
  
  <p>I want to transfer files from one service, the client, to another, the server, via PUT method. The service works, but there is a small point which is not elegant. The files I transfer are getting a new modification date, when I write them on the file system of the server.</p>
  
  <p>At the moment I handle the <code>http.Request</code> at the server like this:</p>
  
  <ul>
  <li>ensure that there is a file at the server</li>
  <li>copy the body from the request to the server <code>io.Copy(myfile, r.Body)</code></li>
  </ul>
  
  <p>When I do that the file has the last modification date from now(). To solve this problem I could transfer a timestamp of the original file and set it via <code>io.Chtimes()</code>. But the request.Body implements an <code>io.ReadCloser</code> interface, so I think there must be a more elegant way to implement the writing of the file onto the server. Is there a function, which takes an <code>io.Reader</code> which preserves the timestamp of the file?
  If not, is there a solution for REST services for this problem?</p>