public async Task DeleteAsync(string[] names) { #region Preconditions if (names == null) { throw new ArgumentNullException(nameof(names)); } #endregion var batch = new DeleteBatch(names); var request = new BatchDeleteRequest(client.Host, bucketName, batch); var result = await client.DeleteObjectsAsync(request).ConfigureAwait(false); if (result.HasErrors) { throw new Exception(result.Errors[0].Message); } if (result.Deleted.Length != names.Length) { throw new Exception("Deleted count not equal to keys.Count"); } }
public async Task DeleteAsync(string[] keys) { var batch = new DeleteBatch(keys); var request = new BatchDeleteRequest(client.Host, bucketName, batch); var result = await client.DeleteObjectsAsync(request).ConfigureAwait(false); if (result.HasErrors) { throw new Exception(result.Errors[0].Message); } if (result.Deleted.Length != keys.Length) { throw new Exception("Deleted count not equal to keys.Count"); } }
public async Task <DeleteResult> DeleteAsync(IReadOnlyList <string> keys) { var batch = new DeleteBatch(keys); var request = new DeleteObjectBatchRequest(client.Host, bucketName, batch); var result = await client.DeleteObjectsAsync(request).ConfigureAwait(false); if (result.HasErrors) { throw new Exception(result.Errors[0].Message); } if (result.Deleted.Length != keys.Count) { throw new Exception($"Only {result.Deleted.Length} of {keys.Count} were deleted."); } return(result); }