Hi there,
I am trying to do a download using FileTransfer, but it gives me an error.
body: null
code: 3
exception: null
http_status: 401
source: "https://media3.giphy.com/media/LR0CgYz1CSmJ6PKiWW/giphy.gif"
target: "file:///storage/emulated/0/Download/test.gif"
I have read on the repo that code 3 means: FileTransferError.CONNECTION_ERR
But I am pretty sure the endpoint does not receive any request (I can notice this using another url pointing a local server).
This is my code (inside the main component of react).
const downloadFile = async () => {
const fileTransfer = FileTransfer.create();
let link = encodeURI("https://giphy.com/stickers/astrology-zodiac-horoscope-LR0CgYz1CSmJ6PKiWW");
let path = File.externalRootDirectory + "Download/";
let file_name = 'test.gif';
let completePath = path + file_name;
fileTransfer.download(link, completePath, true).then((entry) => {
console.log(' download complete: ' + entry.toURL());
}, (error) => {
console.log("error ", error)
});
};
This is my setup:
React app + Ionic + Capacitor
This is the main part of my package.json:
"@capacitor/android": "^2.4.2",
"@capacitor/core": "2.4.2",
"@ionic-native/android-permissions": "^5.28.0",
"@ionic-native/core": "^5.28.0",
"@ionic-native/document-viewer": "^5.28.0",
"@ionic-native/file": "^5.28.0",
"@ionic-native/file-opener": "^5.28.0",
"@ionic-native/file-transfer": "^5.28.0",
"cordova-plugin-android-permissions": "^1.1.0",
"cordova-plugin-document-viewer": "^1.0.0",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-file-opener": "^1.0.0",
"cordova-plugin-file-transfer": "^1.7.1",
"react": "^16.13.0",
I suppose I am using Ionic 5 from the list on the package.json.
Any help?
1 post - 1 participant