【问题标题】:how to select multiple images using react-native-image-crop-picker in react-native如何在 react-native 中使用 react-native-image-crop-picker 选择多个图像
【发布时间】:2020-06-09 07:28:33
【问题描述】:

android 不支持使用 react-native-image-crop-picker 选择多张图片,如何解决?

enter code here

`handlePickImage = async () => { 试试 {

        console.log('hit')
        const images = await ImagePicker.openPicker({
            width: 1000,
            height: 1000,
            cropping: true,
            multiple: true,
            compressImageQuality: 0.5,

        })
        console.log(images)

        for (const image of images) {
            const path = image.path.split('/');
            const fileName = path[path.length - 1]
            console.log('fileNameforVideo', fileName)
            this.setState(
                {
                    files: [... this.state.files, { url: '', type: image.mime.split('/')[0], path: image.path }],
                    file: image.path,
                    fileName,
                    filetype: image.mime.split('/')[0],
                    mimeType: image.mime
                })


            await this.getSingedUrl();
        }

    } catch (error) {

        console.log(error)
        console.log('lol')
    }

` 提前致谢

【问题讨论】:

    标签: react-native file-upload android-image react-native-image-picker


    【解决方案1】:

    我不确定我是否正确理解您遇到的问题,但您使用的库在他们的文档中有一条说明:

    “Android:已知“裁剪”道具会导致视频不显示在 Android 的图库中。选择视频时请不要将裁剪设置为 true。”

    (链接到库 README here

    您似乎正确设置了multiple 选项,但我注意到您将裁剪设置为true,这可能是您的问题的原因。希望对您有所帮助!

    【讨论】:

      【解决方案2】:

      目前可以通过以下方式实现。

      ImagePicker.openPicker({
                  multiple: true,
                  compressImageQuality: 0.5,
      
              }).then(async images => {
              const result = [];
      
              for await (const image of images) {
                  const img = await ImagePicker.openCropper({
                      mediaType: "photo",
                      path: image.path,
                      width: 1000,
                      height: 1000,
                  });
                  result.push(img.path);
              }
      
              return result;
          });
      

      【讨论】:

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