Good Afternoon everyone,
I need help for my Android app:
I’m trying to install and use correctly the FileSystem Plugin, because I need to download files.
Here’s my problem:
I don’t knwo how to save that file in android, how can I do that?
I’m using Quasar + Capacitor + Vuejs 2.
Following my code
methods in my Page:
getDropboxFile(dropboxFileId, dropboxFileIdRootAnnex) {
console.log('download')
const self = this;
axios({
url: 'myurl' +
dropboxFileId +
'/' +
(dropboxFileIdRootAnnex != null ? dropboxFileIdRootAnnex : '-'),
method: 'get',
responseType: 'blob',
showInCatch: 'true',
headers: {
Authorization: self.$store.state.token,
},
})
.then(function(response) {
console.log('sono nella response')
let fileName = response.headers['content-disposition'];
var FileSaver = require('file-saver');
var blob = new Blob([response.data]);
FileSaver.saveAs(blob, fileName);
var path = "Download/" + fileName;
writeFileAndroid(blob,path);
// writeFile(options: WriteFileOptions) => Promise<path>;
})
.catch(function(error) {
console.log('error A1')
console.log(error)
});
},
const writeFileAndroid = async (blob,path) => {
console.log('dentro writeFileAndroid')
let args ={
path: path,
data: blob,
directory: Directory.Documents,
encoding: Encoding.UTF8,
}
await Filesystem.writeFile(args);
console.log('post await')
};
MainActivity.java:
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you’ve installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(Filesystem.class);
add(Storage.class);
}});
super.onCreate(savedInstanceState);
}
}
what am I doing wrong?
Thank you for help!