functionland / react-native-fula

React (JS/Native) wrapper for go-fula/mobile which creates a bridge between Fula and WNFS for React Native to enable developers create mobile native apps
MIT License
2 stars 5 forks source link

The file receive method overwrite issue #4

Closed ghorbani-m closed 2 years ago

ghorbani-m commented 2 years ago

The file.receive method gets the file from the Box and stores it on the phone's storage. If the file still exists on the phone the file will be overwritten and it causes unwanted manipulation of the user files, and in some circumstances, the user lost the original file.

Reproduce issue

  1. Send a file to the box
  2. Edit the file and save it with the same name
  3. Receive file from the box

Issue: The edited file will be overwritten.

Proposal

The solution could be a temp folder to store the files and then if the app wants will move them to another place. Also, we can add a method to clear the temp folder.

farhoud commented 2 years ago

@ghorbani-m

Proposal

For android we can replace reactContext.getFilesDir() this with reactContext.getExternalCacheDir() which is temp of android apps and leave the android to manage it. from there you can decide what to do with it.

ghorbani-m commented 2 years ago

@farhoud, Exactly, here there is another case that used context.getCacheDir().

farhoud commented 2 years ago

Rescive aslo sould return meta

farhoud commented 2 years ago

Look like you satisfy with appdir

farhoud commented 2 years ago

@farhoud, Exactly, here there is another case that used context.getCacheDir().

move the link to https://github.com/functionland/react-native-fula/discussions/8