Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
Silent saving image in electron.js

I have got problem with setting path to download files in this case for images. I download image from URL with blob construction like this:

async function downloadImage(imageSrc) {
    const image = await fetch(imageSrc)
    const imageBlog = await image.blob()
    const imageURL = URL.createObjectURL(imageBlog)

    const link = document.createElement('a')
    link.href = imageURL
    link.download = 'asd.png'
    document.body.appendChild(link)
    link.click()
    document.body.removeChild(link)
} 

Then i catch a download signal on main.js like this:

session.defaultSession.on("will-download", (event, item, webContents) => {
        item.setSavePath( /local_dir/ + item.getFilename());
    }) 

When i log getFilename() i have got correct filename what i want, silent also too works because i havent got a window to locate directory of download, but when i look into directory it is empty.

Thanks for help.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

So i have done this by adding __dirname const to path

item.setSavePath(__dirname + '\\photos\\' + item.getFilename());
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!