ios – How do I read and write to OneDrive using Expo?


I saw in Keepassium it had a DocumentPicker similar to the one in Expo so I presume it’s a standard component. The picker allowed selection to a file on OneDrive.

I know how to make it read the file, but I am not sure it Expo can write to the same file that was obtained through DocumentPicker.

In terms of code here’s what I have

  const picker = useCallback(() => {
    (async () => {
      const x = await DocumentPicker.getDocumentAsync({ copyToCacheDirectory: false, multiple: false, type: "application/json" });
      console.log(x);
      const z = await FileSystem.readAsStringAsync(x.assets[0].uri)
      const zz = JSON.parse(z);
      zz.now = Date.now();
      await FileSystem.writeAsStringAsync(
        x.assets[0].uri, JSON.stringify(zz, null, 2));
      console.log("done writing");
    })();
  }, []);

The log messages appear so it didn’t fail but looking at the the file in OneDrive I don’t see the changes.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img