#divine_code

1 messages · Page 1 of 1 (latest)

somber shardBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1357607308582064241

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

hardy crater
#

Hello! You mentioned that 'it's not working.' Could you please share what you tried and specify what isn't working? Are you encountering any errors?

stark cedar
#

` const handleDownloadPdf = () => {
// Fetch and download the PDF
fetch(
"https://imjwxifnalrkrgfvgili.supabase.co/storage/v1/object/public/docs//stripe app demo pdf.pdf"
)
.then((response) => response.blob())
.then((blob) => {
console.log("STARTING DOWNLOAD");

    // Create a URL for the blob
    const url = window.URL.createObjectURL(blob);

    // Create a temporary link element
    const link = document.createElement("a");
    link.href = url;
    link.download = "invoice.pdf"; // Set the filename

    // Append to the document, click it, and remove it
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);

    // Clean up the URL object
    window.URL.revokeObjectURL(url);

    console.log("PDF downloaded");
  })
  .catch((error) => {
    console.error("Error downloading PDF:", error);
    setError("Failed to download PDF. Please try again.");
  });

// Close the modal after download starts
setShowSuccessModal(false);

};`

#

for this function, although I am getting the logs in browser console but nothing about the download in browser

hardy crater
#

do you see any error in the Developer console?

stark cedar
#

nope nothing

#

I tried just this as well window.open( "https://imjwxifnalrkrgfvgili.supabase.co/storage/v1/object/public/docs//stripe%20app%20demo%20pdf.pdf", "_blank" ); but it says can not open link as it is in a sandboxed env inside stripe

hardy crater
#

hmmm, I don't think what you want is possible. I think the way to go about it is to create a Link element with the href to your external PDF file i.e. "https://imjwxifnalrkrgfvgili.supabase.co/storage/v1/object/public/docs//stripe%20app%20demo%20pdf.pdf"

stark cedar
#

okay got it, so can I still redirect user to that pdf ?