【问题标题】:How to delete react-native-image-crop-picker image from /storage/emulated/0/Pictures如何从 /storage/emulated/0/Pictures 中删除 react-native-image-crop-picker 图像
【发布时间】:2020-02-17 12:24:45
【问题描述】:

当图像被捕获时,它会保存两张图像,一张是原始的,另一张是压缩的,并在image.path 中给出压缩图像的路径。如何禁用在图库中保存任何图像,我只需要使用 base64 即可?

ImagePicker.openCamera({
  cropping: true,
  width: 300*3,
  height: 400*3,
  includeBase64: true,
  mediaType:'photo',
}).then(image => {
  console.log('received image');
  console.log(image)
})

输出如下:

cropRect: {height: 4128, width: 3096, y: 0, x: 0}
data: "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQ"
height: 900
mime: "image/jpeg"
modificationDate: "1581938243000"
path: "file:///storage/emulated/0/Pictures/398da0f6-73ee-47ce-bfdd-8b0fa68312a5.jpg"
size: 353210
width: 675

【问题讨论】:

  • 设法解决?我有同样的问题
  • 你找到解决这个问题的方法了吗?

标签: react-native react-native-fs react-native-image-picker


【解决方案1】:

一种解决方法是删除保存的图像。 您可以通过执行来使用 fs 包

var RNFS = require('react-native-fs');
RNFS.exists(image.path)
.then(path => RNFS.unlink(path)) 

另外,它还保存在 tmp 目录中,所以也用这个

ImagePicker.clean().then(..)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-13
    • 1970-01-01
    • 2019-07-16
    • 2021-09-28
    • 1970-01-01
    • 2021-05-11
    • 2020-07-17
    • 1970-01-01
    相关资源
    最近更新 更多