Can I not input file name when downloading using FileTransfer?

I am using FileTransfer plugin to download a file.
But I want to use the original filename of the file but not a one I assigned.
Can I keep the original file name when downloading it?

ie. I don’t want to change 'file.pdf' manually in below code:

fileTransfer.download(url, this.file.dataDirectory + 'file.pdf').then((entry) => {
    console.log('download complete: ' + entry.toURL());
  }, (error) => {
    // handle error
  });

Thanks

PS. My url will not contain any file name (will be something like: https://domain.net/<id>?sp=r&st=2020-07-22&sig=<other-id>&srt=o&ss=b" ) so it is quite not possible to get the filename from the url. But if open the link in browser, I can download it with a meaningful filename.

This isn’t a great idea. That plugin has been obsolete for a couple of years now. I would recommend just using HttpClient to fetch and Capacitor’s Filesystem to write.

There is no such thing as “the original file name”. Assets served over HTTP are frequently not even files on the server; they can be retrieved from databases, built on the fly, &c.

The server can indicate a recommended filename to use; typically this is done via the Content-Disposition header. If yours does, then I would suggest reading that header. If it doesn’t, then I would suggest adding said header, or bothering whoever can do that.

Thank you for your reply. But I not quite sure how to implement it using HttpClient and Filesystem. It would be grateful if you can provide some sample code.

And for the filename, if I go to the link in my desktop browser, it will show up a file for me to download and it do have a filename. What I want is keep this filename and not assigned by me from code. Is it possible?

Thanks