Open ahyong87 opened 6 years ago
I'm having this same issue. I do not want the image to persist on the Android device's gallery. I only want the base64 string which, in my case, I send to a server and after that I am done with the camera/gallery and don't want any remnants left on the device.
I'm also facing this issue when i use the picker with multiple images it doesn't save any of the images that user selected, but on other case where I only need to pick 1 image with cropping enabled, it saves that image to "storage/emulated/0/Pictures" Note: I have also tried using "ImagePicker.clean()" but the results remain the same"
This issue will clog the mobile storage with unwanted junk images. Is there no way to stop this from happening?
Any solution to this?
LAZIEST SOLUTION I CAN THINK OF: You guys are generating random name for both original and compressed image atleast generate once for original image and add "_compressed" or expose a property for end user to choose the suffix string for the compressed image so that the same end user can take care of the issue.
Anybody found any solution to this? @vemulanishanth how do we set names for original and cropped images in android?
I know react-native-camera' doNotSave prop solves this, does anybody know if it could be inherited in this lib?
try update to "react-native-image-crop-picker": "^0.36.0" and in android/build.gradle update to this version classpath("com.android.tools.build:gradle:3.5.4")
Any solution?, I have the same problem
Ok ... I have a quick fix. The "react-native-fs" library contains a method for deleting files.
So we create a function with the following code:
const DeleteFile = (path) => { RNFS.unlink(path) }
Then we call the function within the method that performs the capture / selection of the image:
const takePickSingleWithCamera = (cropping, mediaType = 'photo') => {
ImagePicker.openCamera({
cropping: cropping,
width: 500,
height: 500,
includeBase64: true,
includeExif: true,
mediaType,
})
.then((image) => {
setCameraPick(image.data)
DeleteFile(image.path)
})
.catch((e) =>
Alert.alert(e));
}`
The instant the photo is uploaded and the Base64 is obtained, the image will be removed from the directory. It is useful if our objective is only Base64 and to avoid storing unnecessary images.
My Versions: "react": "16.13.1", "react-native": "0.63.4", "react-native-image-crop-picker": "^0.35.1", "react-native-fs": "^2.17.0"
@alejandrosazo I don't think you get the issue here. I do not know if the issue is still present right now.
But when I faced the issue, I clearly remember the workflow to reproduce it.
after digging through the commits you find in the following links that the original image is not being deleted after the compressed/resized image is created
Version
Tell us which versions you are using:
Platform
Tell us to which platform this issue is related
Expected behaviour
Actual behaviour
Steps to reproduce
App path "file:///data/user/0/com.vaneijck/cache/react-native-image-crop-picker/90e9e92f-faf6-463b-98b7-f5a0da5aae99.jpg"
try ImagePicker.clean also not work
Attachments
// stacktrace or any other useful debug info
Love react-native-image-crop-picker? Please consider supporting our collective: 👉 https://opencollective.com/react-native-image-crop-picker/donate