ibrod83 / nodejs-file-downloader

129 stars 23 forks source link

How to auto set extension with custom fileName? #54

Closed xmsz closed 1 year ago

xmsz commented 1 year ago
 const downloader = new Downloader({
      url: "http://wx.qlogo.cn/mmhead/ver_1/89YLLIPBBfACbl3Wlanq1xkYSouia2oe5um1Hvx3QPRSdF5ddnF3uNPOnbznduFtcPycjzEZ6GsibabQqTuje1I1JOERNLCQN88q85OibSTFCw/0",
      directory: './download/',
    });

I want set custom fileName, but i can't get the file extension.

maybe, it can be this way

 const downloader = new Downloader({
      url: "http://wx.qlogo.cn/mmhead/ver_1/89YLLIPBBfACbl3Wlanq1xkYSouia2oe5um1Hvx3QPRSdF5ddnF3uNPOnbznduFtcPycjzEZ6GsibabQqTuje1I1JOERNLCQN88q85OibSTFCw/0",
      directory: './download/',
      fileName: ({extension}) => {
           return `${customFileName}.${extension}`
      }
    });
xmsz commented 1 year ago

https://github.com/ibrod83/nodejs-file-downloader#get-the-deduced-file-name-and-override-it

ibrod83 commented 1 year ago

is it working for you?

xmsz commented 1 year ago

is it working for you?

yes