ammarahm-ed/react-native-scoped-storage

How to copy image file from one folder to another?

ghulamabbas2 opened this issue · 1 comments

I have written this code:

ScopedStorage.copyFile(item.uri, dir.uri)
      .then(res => {
        console.log(res);
      })
      .catch(err => {
        console.log(err);
      });

The app crashes when I click on the button to copy the file. Can anyone provide me the correct way to copy file?

@ghulamabbas2 First create the file you want to copy using ScopedStorage.createFile then use the returned url in copyfile to write it's contents.

const file = await ScopedStorage.createFile(...);
ScopedStorage.copyFile(item.uri, file.uri)
      .then(res => {
        console.log(res);
      })
      .catch(err => {
        console.log(err);
      });