Answers for "download file .net core"

C#
0

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");
            }
        }
Posted by: Guest on June-17-2021

C# Answers by Framework

Browse Popular Code Answers by Language