public void CopyObject(Uri sourceUri, Uri destinationUri)
{
CheckUri(sourceUri);
CheckUri(destinationUri);
try
{
TryCreateDirectory(CutLastDirectoryFromUri(destinationUri.AbsoluteUri), true);
var response = DownloadObject(sourceUri);
var request = new UploadRequest();
request.Uri = destinationUri;
request.InputStream = new MemoryStream();
response.ResponseStream.Position = 0;
response.ResponseStream.CopyTo(request.InputStream);
UploadObject(request);
}
catch (Exception e)
{
throw new StorageException(string.Format("Failed to copy object. SourceUrl: {0}, DestinationUrl: {1}", sourceUri, destinationUri), e);
}
}