title: How do I download a file on click in reactjs from download Url firebase storage?
body: <p>This is what I implemented:</p>
  <pre><code>downloadFile=(file)=&gt;{
          var element=document.createElement('a');
          element.style.display= &quot;none&quot;;
          element.setAttribute('href', file.fileUrl)
          element.setAttribute(&quot;target&quot;, &quot;_blank&quot;);
          document.body.appendChild(element)
          element.click()
          document.body.removeChild(element) 
      } 
  </code></pre>
  <p>This is working fine for .ai files but not for .pdf or .jpeg. Instead of downloading the file, the browser opens it in a separate window. I want to enable download file feature and not open file. How do I fix this issue? Is there an alternative way to download the file from url from browser?</p>