Set directory to download file from Internet

I wanted to save images by links from an API and there’s a part of official docs guiding so. Anyway, I couldn’t set the directory to save the files and get the path to insert into sqlite database.

Here’s the function:

public download(url) {
let fileName = url.substring(url.lastIndexOf('/') + 1, (url.length)); 
//set directory to replace this.file.dataDirectory
//or how to use the file.dataDirectory
//this.imagePath = ...
this.fileTransfer.download(url, this.file.dataDirectory + fileName, true).then((entry) => {
//get back the path to the image on device storage
}, (error) => {

  });
  return this.imagePath;
} 
1 Like