public async Task <bool> CopyFileAsync(string path, string targetPath, CancellationToken cancellationToken = default) { if (String.IsNullOrEmpty(path)) { throw new ArgumentNullException(nameof(path)); } if (String.IsNullOrEmpty(targetPath)) { throw new ArgumentNullException(nameof(targetPath)); } try { var copyResult = await Task.Factory.FromAsync( (request, callback, state) => _client.BeginCopyObject(request, callback, state), result => _client.EndCopyResult(result), new CopyObjectRequest(_bucket, NormalizePath(path), _bucket, NormalizePath(targetPath)), null ).AnyContext(); return(copyResult.HttpStatusCode == HttpStatusCode.OK); } catch (Exception) { return(false); } }
private static void CopyObjectCallback(IAsyncResult ar) { try { client.EndCopyResult(ar); Console.WriteLine("Copy object succeeded"); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { _event.Set(); } }
private static void CopyObjectCallback(IAsyncResult ar) { try { var result = client.EndCopyResult(ar); Console.WriteLine(result.ETag); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { _evnet.Set(); } }