H5 end mobile download files function, found that some word files can be opened online and some can not open, suggesting that "can not preview this file, it may corrupt";
But in the end download Pc is normally open, mobile end is not.
code show as below:
byte[] array = result.DecryptContent;
MemoryStream stream = new MemoryStream(array);
StreamReader reader = new StreamReader(stream);
var contentType = "application/msword";
if (result.FileName.Contains(".docx"))
{
contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
}
return File(stream, contentType, result.FileName);
It can be seen contentType different types, can cause a preview, an error occurred while downloading, when he converted preview.
Hence the need for different types of word version is set contentType value can be, some people will pay attention docx file is created and then changed the name doc, it will also convert error.