capacitor-file-selector
capacitor-file-selector copied to clipboard
Unable to fetch the selected file
const file = await fetch(selectedFile.paths[index]).then((r) => r.blob());
This is not working for me (in my Vue app using Nuxt). It will always return the index.html (or an empty gif).
When I remove the "_capacitor_file_" bit like so:
let path = paths[index].replace("_capacitor_file_", "");
And grab the file this way:
const file = await fetch(Capacitor.convertFileSrc(path)).then(r => r.blob());
That way it does work. What am I doing wrong? It took some time getting it to work. I hope by posting this, it will help others out.
Hello @peterarends
You can also create the blob type by this way
const blob = new Blob([data.item(i)], {type: data.item(i).type});