Mobiles: downloading docx files, sometimes there is an error showing up that the file is corrupted

71 Views Asked by At

In my application, we have a notification functionality, when a link is completed by an user. That notification will have a link to file stored on server. While sending the notification I'm preparing a link to file like this

<a href='LINKTOFILEOnSERVER'>FileName</a>

This is what also stated here

Now, in the post above there is point to set "content-type" and "Content-Disposition" but I'm not sure how can I set this in my case.

Can anyone help here?

1

There are 1 best solutions below

1
On

The web server which will serve the file will need to set those headers. You cannot set those in anchor element.

If the files are static (physically located on disk), one way to do it for IIS is to set HTTP response headers for all requests coming to the folder where the files are located:

<configuration>     
  <!--set custom headers for "docs" folder -->
  <location path="docs">
    <system.webServer>
      <httpProtocol>
        <customHeaders>
          <add name="Content-Disposition" value="attachment; filename=&quot;file.docx&quot;"/>
          <add name="Content-Type" value="application/octet-stream" />
        </customHeaders>
      </httpProtocol>
    </system.webServer>
  </location>    
</configuration>