Closed ShivamJoker closed 2 years ago
I am trying using the external cp but getting
Error: Failed to copy to 'downloads'
Assuming Android, have you tried requesting WRITE_EXTERNAL_STORAGE
https://reactnative.dev/docs/permissionsandroid ?
Okay even after adding permission that it is not working
LOG file:///data/user/0/com.introverttest/cache/5fc1e891-2b3c-4dab-b85f-dc290b3d6cbdimagemarker.jpg
LOG [Error: Failed to copy to 'downloads' ('Introvert Certificate.jpg')]
const handleDownload = async () => {
try {
console.log(imgUri);
await checkStoragePermission();
const url = await FileSystem.cpExternal(
imgUri,
'downloads',
'Introvert Certificate.jpg',
);
console.log('copied', url);
} catch (err) {
console.log(err);
}
};
Looks like arguments are reversed. Try:
await FileSystem.cpExternal(
imgUri,
'Introvert Certificate.jpg',
'downloads',
);
(Related, if you decide to switch to using TypeScript at some point, this library includes definitions that should give a warning for this type of situation.)
Damn 🥺 yeah I generally use typescript in my projects but this was for someone else.
Thanks for replying
Hello thanks for your great work Can we also save the files in download directory ?