How to download S3 image using rails?

how to download S3 image using rails?

Button code:

.submit-btns-download.bottom-btns button.btn.btn-primary.float-right.btn-radius.final_download type=“button” #{translate(‘gallery.download’)}

script:

(".final_download").click(function(event){ if((".checkbox:checked").length > 0 ){ var img_url = ; .each((".checkbox:checked"), function(){ img_url.push((this).parent().find('img').attr('src')); var img = (this).parent().find(‘img’); var link = document.createElement(“a”); link.href = img[0].src; link.download = true; link.target = “_blank”; link.style.display = “none”; var evt = new MouseEvent(“click”, { “view”: window, “bubbles”: true, “cancelable”: true });

      document.body.appendChild(link);
      link.dispatchEvent(evt);
      document.body.removeChild(link);
      console.log("Downloading...");
    });
  } else  {
    alert("Please select a file.");
  } 
});

Check this: Active Storage Overview — Ruby on Rails Guides