/// <summary> /// Removes object from storage /// </summary> /// <param name="objectId">Object Id</param> /// <param name="bucketName">Bucket name - Optional if passed throuhg constructor</param> /// <returns></returns> /// <exception cref="EndpointUnreachableException">Thrown when S3 endpoint is unreachable.</exception> /// <exception cref="S3BaseException">Thrown when exception is not handled.</exception> public async Task RemoveObject(string objectId) { var s3Obj = BucketHelper.ExtractObjectInfo(objectId); var bucket = s3Obj.bucketName?.ToLower() ?? _bucketName; var objectName = s3Obj.objectName; try { await _requestRetryPolicy.ExecuteAsync(async() => { await _objectOperationsClient.RemoveObjectAsync(bucket, objectName); }); } catch (MinioException ex) when(ex is ConnectionException || ex is InternalServerException || ex is InternalClientException || ex is InvalidEndpointException ) { throw new EndpointUnreachableException(_endpoint, ex.ToString()); } catch (S3BaseException) { throw; } catch (Exception ex) { throw new S3BaseException(ex.Message, ex.ToString()); } }