Can't copy PNG to custom directory

Please provide the following:

  1. SDK Version: 34.0.0
  2. Platforms(Android/iOS/web/all): IOS

Using takeSnapshotAsync I capture an image which is automatically saved as a temp file in the app’s cache directory. However, I do not want this file to be deleted unless the user wants it to be deleted, so I need to move it to the document directory. I created a new directory called myAppFiles using makeDirectoryAsync, which works successfully.

I then take the snapshot, it is saved in the cachedirectory, but when I try to copy it over to my custom directory using FileSystem.copyAsync(), I get the following error:

[Unhandled promise rejection: Error: File ‘file:///private/var/mobile/Containers/Data/Application/20DB1A71-8DB3-45DD-BA8D-B17827EBB820/tmp/ReactABI34_0_0Native/7B19A559-E43F-41AC-AAD3-224193204C47.png’ could not be copied to ‘file:///var/mobile/Containers/Data/Application/20DB1A71-8DB3-45DD-BA8D-B17827EBB820/Documents/ExponentExperienceData/%2540username%252FMyApp-RN/myAppFiles/TWiRDknD’.]
- node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:155:41 in createErrorFromErrorData
- node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:104:55 in
- … 5 more stack frames from framework internals

I created a snack using the exact same process I’m using, and the snack seems to have no problems doing this. Can anyone tell me why I’m getting the error in my application, but the snack works fine?

SideNote: In my application, if I check to see if the custom directory exists, It returns true. But when I use FileSystem.readDirectoryAsync() to enumerate through the directory, it also throws an error saying it cannot be read.

Working Snack: Local Saving - Snack

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.