download file .net core
public IActionResult Get(string Id)
{
try
{
byte[] bytes = mongoDBGridFSRepository.GetFile(new ObjectId(Id));
return new FileContentResult(bytes, "application/octet-stream");
}
catch (Exception ex)
{
logger.LogError($"Exception when fetching file with stack trace: {ex.StackTrace}");
return StatusCode(StatusCodes.Status500InternalServerError, "Error Saving File");
}
}