Git Product home page Git Product logo

Comments (2)

scottbot95 avatar scottbot95 commented on July 18, 2024 1

For anyone that's having a similar problem, the best workaround I found that works for my use case is to set the directory in BOTH the registration call ( ie electronDl({directory: '...'})) and the calls to download()

from electron-dl.

ravisojitra avatar ravisojitra commented on July 18, 2024

Hello @scottbot95

My Problem: I have a chat app where user enters any chat room all images from that room will be downloaded one by one and i want to avoid saveAs dialog everytime. So, After user selects path first time i store it in config and check next time as shown below, if i get path then it shouldn't ask path again. But it still asks prompt for path.

I even removed property saveAs(defaults to false), but again when there are 6-7 images, it downlods 3 images without prompt, and for next ones it asks prompts to save It. So how to handle this situation?

can you please show me some sample code?

This is how i'm using it as you suggested.

const electronDl = require('electron-dl');
const download = electronDl({ saveAs: false, directory: app.getPath('downloads') });

let savePath = config.get('savePath');
  download(
    mainWindow,
    args.imgUrl,
    {
      filename: `${args.msgTime}.jpg`,
      openFolderWhenDone: true,
      directory: savePath || app.getPath('downloads'),
      showBadge: false
    }
  ).then((downloadObj) => {
    if (!savePath) {
      let savedPath = downloadObj.getSavePath();
      let splitted = savedPath.split('/');
      splitted.pop();
      config.set('savePath', splitted.join('/'));
    }
  }).catch((err) => {
    event.sender.send('imageDownloadFailed', { msgTime: args.msgTime })
  });

But then it gives error that download is not a function.

from electron-dl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.