Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
how to download static file in gatsby js

I have a website with Gatsby.JS
I want to when click download button, download one static pdf file.

<button>
    <a download={`../../file.pdf`}> İndir</a>
</button>

this ../../file.pdf is path of static folder.
Above code my downloadable code.

But this is not work. How can i fix.?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The download attribute, summarizing a lot is just a way to set the name of the downloadable element but it's the href attribute the one that must point to the item you want to download.

This should work:

<a download={`Some Fancy Name`} href={`../../file.pdf`}>İndir</a>

Double-check the ../../file.pdf path to ensure that is valid or that the file.pdf belongs to that route.

The static folder replicates its internal structure to the public (/public) one when the site builds. So, a structure like: /static/file.pdf should be pointed as:

<a download={`Some Fancy Name`} href={`/file.pdf`}>İndir</a>

Since the static folder becomes the "root", the level 0.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda