Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution Provided for : issue #2 File Saver npm Package not working after hosting #74

Open
ItsAnkitPatel opened this issue Mar 26, 2024 · 0 comments

Comments

@ItsAnkitPatel
Copy link

ItsAnkitPatel commented Mar 26, 2024

Inside utils/index.js update the downloadImage function

export async function downloadImage(_id, photo) {
  const securePhotoUrl = photo.replace('http://', 'https://');
  const imageBlob = await fetch(securePhotoUrl)
    .then((response) => response.arrayBuffer())
    .then((buffer) => new Blob([buffer], { type: "image/jpg" }));
  const url = URL.createObjectURL(imageBlob)
  FileSaver.saveAs(url, `download-${_id}.jpg`);
}

This worked for me.

The error message I was facing is due to the "Mixed Content" policy enforced by modern browsers. This policy disallows loading insecure (HTTP) content from a secure (HTTPS) site.

Your site is served over HTTPS, but it's trying to load an image from an HTTP URL. This is what's causing the error.

To fix this, you need to ensure that all resources are loaded over HTTPS.

@ItsAnkitPatel ItsAnkitPatel changed the title Solution Provided for : for issue(#2) File Saver npm Package not working after hosting Solution Provided for : issue #2 File Saver npm Package not working after hosting Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant