I am having a difficult time attempting to download a pdf file from my react app onto my Desktop. I've posted the question before with the details found here How to download pdf file with React. Now I've received an answer but implementing it and the subsequent suggestions have turned out flat. I thought however that people who have not seen this question yet could potentially help me because I'm having a real tough time solving this one. So here goes.
I have a react app with the following tree structure:
app
|
|- Readme.md
|- index.html
|- node_modules
|- package.json
|- resume.pdf -------> This is the file I want downloaded
|- src
|
|-App.css
|- App.js
|- App.test.js
|- favicon.ico
|- index.css
|- index.js
|- assets
|-modules
|-skills.js -----> Here is where I reference it.
This is part of my skills.js
where I reference the <a>
link:
class Skills extends Component {
render() {
return (
<div>
<ReactHighcharts neverReflow={true} config={highchartConfig} domProps={{id: 'chartId'}}></ReactHighcharts>
<a href="resume.pdf" download="resume.pdf">Click to Download My Resume</a>
</div>
);
}
}
When I click the button on Chrome I get a Failed - No File
error. I was told to have this directory structure like so and reference the pdf document as such in the <a>
link.
When I try hit the link localhost:3000/resume.pdf
in the the console I see this error browser.js:49 Warning: [react-router] Location "/resume.pdf" did not match any routes
When I try the same thing in Firefox and download it firefox says
The file resume.pdf could not be opened. It may be damaged or use a file format that Preview doesn't recognize.
I could really use some help here. I am not sure why I'm unable to download this pdf at all. Does anyone out there know what could be the problem?