public async Task <IActionResult> UploadCertificateAsync(int invoiceId, IFormFile file) { if (file == null || file.Length == 0) { throw new IllegalArgumentException("InvalidFile", "File cannot be empty"); } using (var stream = new MemoryStream()) { await file.CopyToAsync(stream); await _documentGenerationManager.UploadCertificateForInvoiceAsync(invoiceId, stream, file.FileName); } return(NoContent()); }