Code Monkey home page Code Monkey logo

Comments (10)

dmarcs avatar dmarcs commented on July 26, 2024

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.

from react-native-document-scanner-plugin.

eduardfarkas avatar eduardfarkas commented on July 26, 2024

@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.

from react-native-document-scanner-plugin.

hm1061998 avatar hm1061998 commented on July 26, 2024

@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?

from react-native-document-scanner-plugin.

eduardfarkas avatar eduardfarkas commented on July 26, 2024

@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)

from react-native-document-scanner-plugin.

dmarcs avatar dmarcs commented on July 26, 2024

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

from react-native-document-scanner-plugin.

eduardfarkas avatar eduardfarkas commented on July 26, 2024

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.

from react-native-document-scanner-plugin.

dmarcs avatar dmarcs commented on July 26, 2024

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

from react-native-document-scanner-plugin.

eduardfarkas avatar eduardfarkas commented on July 26, 2024

@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

from react-native-document-scanner-plugin.

silencie avatar silencie commented on July 26, 2024

@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}
    />
  )
}

from react-native-document-scanner-plugin.

eduardfarkas avatar eduardfarkas commented on July 26, 2024

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) => {});
    });
};

from react-native-document-scanner-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.