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

151
Visualizações
How to specify the filename during download over HTTP

I currently store my woocommerce product files on S3 in the following format:

/bucket/{product_id}.zip

When a customer clicks the download link in their customer dashboard the element is as follows:

<a href="https://url/1234.zip">Download Product Name</a>

This downloads the file into their downloads folder as 1234.zip

I would like to be able to pass some values to the request so that the filename can be downloaded as {param1}-{param2}.zip

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Like this:

<a href="https://url/1234.zip" download=`${param1}-${param2}.zip`>Download Product Name</a>

Refer: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download

Note:

download only works for same-origin URLs, or the blob: and data: schemes. How browsers treat downloads varies by browser, user settings, and other factors. The user may be prompted before a download starts, or the file may be saved automatically, or it may open automatically, either in an external application or in the browser itself. If the Content-Disposition header has different information from the download attribute, resulting behavior may differ: If the header specifies a filename, it takes priority over a filename specified in the download attribute. If the header specifies a disposition of inline, Chrome and Firefox prioritize the attribute and treat it as a download. Old Firefox versions (before 82) prioritize the header and will display the content inline.

about 4 years ago · Santiago Trujillo Relatório

0

When they click a button to download the file, you can add the HTML5 attribute "download" where you can set the default filename.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download

<a href="https://url/1234.zip" download={${param1}-${param2}.zip}>Download Product Name

about 4 years ago · Santiago Trujillo 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