The best feature on this site (in my opinion)!

Last year, I added by far my favourite feature onto my website - the download CV button. I loved it so much, that I made a video - that you can see above!

At the time of creation, I thought it was a wicked idea: recruiters would visit my site and instantly smash the "download my CV" button, and I would be drowning in jobs in no time... Well that didn't happen, but I had a lot of fun implementing it. I showed the code to my colleagues/friends, and they loved it too! So much so, they added it to their website (Thanks Dan).

How does it work?

I store and edit my CV in a Google Doc on my personal account. I prefer this way since I am used to Google Docs, and don't really want to faff around with MD(X) if I don't have to.

The rest is made up of these three things:

And.... here's the function that does the heavy lifting:

export const downloadCV = async () => {
    const url = `https://www.googleapis.com/drive/v3/files/${import.meta.env.VITE_DOCUMENT_ID}/export?key=${import.meta.env.VITE_API_KEY}`
    const response = await axios.get(url, { responseType: 'blob', params: { 'mimeType': 'application/pdf' } })
    try {
        download(response.data, 'Name_Of_your_file.pdf', 'application/pdf')
    } catch (error) {
        console.debug(`Error getting file: ${error}`)
    }
}

It's really simple: all it does is make a GET request to the Google Drive API using Axios, and downloads the binary object it recieves.

How do I get the variables?

You need to create enable the Google Drive API in your Google Cloud project, and then restrict an API key to the Drive API.

To get the Document ID, you just grab it from the URL of your Google Doc.

If that didn't make sense, please watch the video hehehe.

Just give me the code.

Ok wow, is this relationship purely transactional? fine.

I have a full working example in React that you can use.