Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How are images stored? #56

Closed
eduardfarkas opened this issue Jan 31, 2023 · 10 comments
Closed

How are images stored? #56

eduardfarkas opened this issue Jan 31, 2023 · 10 comments

Comments

@eduardfarkas
Copy link

Hi,
I would like to ask about storing images.
If I take jpg picture, is it cached or stored somewhere permanently?

What are the ways to manage this? Should i delete those pictures manually?

Thanks in advence

@dmarcs
Copy link
Contributor

dmarcs commented Jan 31, 2023

Images are stored as files on Android and iOS. If a user deletes the app, the files get deleted.

You can store them somewhere else like S3 if you want, and you can delete them manually.

@dmarcs dmarcs closed this as completed Jan 31, 2023
@eduardfarkas
Copy link
Author

@dmarcs i would like to delete scans that i have processed, but with expo filesystem i cannot do it.
How do I delete scans that I no longer need? I don't want to bloat memory with unneccessary images.

@hm1061998
Copy link

@dmarcs i would like to delete scans that i have processed, but with expo filesystem i cannot do it. How do I delete scans that I no longer need? I don't want to bloat memory with unneccessary images.

I also have the same problem, the image files after scanning are not automatically deleted causing the memory to be full.
using expo-file-system cannot delete them.
have you solved it yet?

@eduardfarkas
Copy link
Author

@hm1061998 not really, i saw that expo-media-library should do the trick because it can access camera roll folder (i didnt try it yet), but the path to the file is in the scope of the app if i understand it right, so expo-file-system should work.
Anyway, for now I am waiting for @dmarcs to answer it.

(and i hope there is a way to delete it, otherwise i dont know what will i do :D)

@dmarcs
Copy link
Contributor

dmarcs commented Feb 2, 2023

@hm1061998 @eduardfarkas can't you use https://docs.expo.dev/versions/latest/sdk/filesystem to delete the files?

@eduardfarkas
Copy link
Author

It says that the file is not deletable. I have tried to modify the path a little bit just in case it was wrong but i had no success.
I would like to ask you to try to reproduce it on your end. I tried it on android simulator on macos.

@dmarcs
Copy link
Contributor

dmarcs commented Feb 4, 2023

I was able to delete files using https://www.npmjs.com/package/react-native-fs.

@eduardfarkas
Copy link
Author

eduardfarkas commented Feb 9, 2023

@dmarcs sorry for delay, i tried this library https://github.com/DylanVann/react-native-fast-image and i was also able to delete the image.
I suggest putting this information in the readme so other users will be aware that images must be deleted with external library.
btw, thank you for trying it yourself

@silencie
Copy link

silencie commented May 8, 2023

@dmarcs sorry for delay, i tried this library https://github.com/DylanVann/react-native-fast-image and i was also able to delete the image. I suggest putting this information in the readme so other users will be aware that images must be deleted with external library. btw, thank you for trying it yourself

How did you do that ? Can you show code examples ?

import FastImage from 'react-native-fast-image'
import DocumentScanner from 'react-native-document-scanner-plugin'

export default () => {
  const [scannedImage, setScannedImage] = useState();

  const scanDocument = async () => {
    const { scannedImages } = await DocumentScanner.scanDocument()
  
    if (scannedImages.length > 0) {
      setScannedImage(scannedImages[0])
    } 

    FastImage.clearMemoryCache() <<< Did you delete the image by adding this line ?

  }

  useEffect(() => {
    scanDocument()
  }, []);

  return (
     <FastImage
        style={{ width: 200, height: 200 }}
        source={{
            uri: scannedImage,
            priority: FastImage.priority.normal,
        }}
        resizeMode={FastImage.resizeMode.contain}
    />
  )
}

@eduardfarkas
Copy link
Author

Hi @silencie,
sorry for the trouble, I definatelly meant to link different library. react-native-fast-image is not meant to handle this.
I am using react-native-file-access

Here is code snippet i use:

import { FileSystem } from "react-native-file-access";

const deleteImageFromMemory = (path: string) => {
    FileSystem.exists(path).then((exists) => {
        exists && FileSystem.unlink(path).then((result) => {});
    });
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants