Hi
System.Web.HttpContext.Current.Response.ContentType = mimeType;
If I understand correctly, you need to set the mimeType variable to the proper content type. However the contentType field in the database is not a proper MIME type. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types for a description of valid MIME types.
You didn’t specify how you query the relevant file, but in the mongo shell the code should look similar to:
var file = db.Txt.files.findOne({_id: <the file _id>})
var contentType = file.contentType
If executed in the mongo shell, the contentType variable should contain e.g. .txt as stored in the database.
System.Web.HttpContext.Current.Response.AddHeader(“content-disposition”, “attachment; filename=” + FileID + “.pdf”);
Having said that, I’m not sure I understand why the pdf extension is hardcoded in the next line. Is this intentional?
For more information, please see:
Best regards
Kevin