public async Task <string> Upload(IFormFile model) { try { //check if the image is less than 200kb if (model != null && ((model.Length / 1048576.0) < .2)) { using (var stream = new MemoryStream()) { model.CopyTo(stream); var fileBytes = stream.ToArray(); var op = _imageService.StoreProfile(model.FileName, fileBytes); op.Wait(); if (!op.IsCompletedSuccessfully) { _logger.Log(LogLevel.Error, $"Unable to upload image file: {op.Exception}"); throw op.Exception; } return(await op); } } return(""); } catch (Exception) { throw; } }