简体   繁体   English

从网站下载时PDF中断

[英]PDF breaks when downloaded from a website

This is my code: 这是我的代码:

<a style={{marginLeft: '10px', width: '100%'}} download
    href={'/assets/Polityka-prywatnosci.pdf'}>
    Przeczytałem(-am) i rozumiem politykę ochrony
    prywatnosci.
</a>

I am using Reacj.js. 我正在使用Reacj.js。

So I need this file to be downloadable. 因此,我需要此文件可下载。 To make things strange it works when I use yarn start and use the localhost:3000 route, but as soon as I push it to the live server the pdfs get corrupted. 使事情变得奇怪的是,当我使用yarn start并使用localhost:3000路由时,它可以工作,但是一旦将其推送到实时服务器,pdf便会损坏。

The pdfs in the build folder are valid and I can open them in a pdf viewer. build文件夹中的pdf有效,我可以在pdf查看器中打开它们。 So I think something is messing up when downloading the file. 因此,我认为下载文件时有些混乱。 What am I doing wrong? 我究竟做错了什么?

可以与服务器上与应用程序用户相关的特权有关

I ended up using google drive to host the file. 我最终使用谷歌驱动器来托管文件。 A cheat but it works 作弊,但有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM