“.heif”文件未下载,服务器返回 404 Not Found 错误

'.heif' file is not downloading, server is returning 404 Not Found error

用于下载 .heif 扩展名的锚 link 无效。我收到 404 Not Found 错误,但文件存在于服务器上。同样的 link 适用于所有已知类型的文件,例如 'png, jpeg, pdf, docx etc'。我正在使用以下锚标记来下载文件:

    <a ng-href="{{clientProfile.stdidentityDocObj.payeE_DOCUMENT_FILE}}"
                               target="_blank" download>Download
    </a>

我得到的错误是:

该网站部署在 Windows Server 2016 上。这可能是什么问题?有什么方法可以让我也能下载这些类型的文件吗?

您需要将文件扩展名告知 IIS,有关详细信息,请参阅 this doc,但它指出:

IIS 7 will not return file types that are not added to the <staticContent> element or that have mappings in the <handlers> element by default. This behavior prevents unauthorized access to files that do not have mappings in the IIS 7 configuration settings.

因此,要解决此问题,请添加一个 staticContent 元素:

<configuration>
   <system.webServer>
      <staticContent>
         <!-- Add this line... -->
         <mimeMap fileExtension=".heif" mimeType="application/octet-stream" />
      </staticContent>
   </system.webServer>
</configuration>