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.