Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在imageManipulator中使用通过DocumentPicker获得的本地文件uri。利用世博会_Java_Reactjs_React Native_Expo - Fatal编程技术网

Java 如何在imageManipulator中使用通过DocumentPicker获得的本地文件uri。利用世博会

Java 如何在imageManipulator中使用通过DocumentPicker获得的本地文件uri。利用世博会,java,reactjs,react-native,expo,Java,Reactjs,React Native,Expo,好的,我使用expo来管理我的react原生应用程序,在我的一项功能中,我允许用户选择要上传的文件,问题是用户可以选择任何类型的文件,因此我使用DocumentPicker,用户可以选择他想要上传的文件,问题是由于一些服务器容量问题,我需要使用ImageManipulator来操作图像,这样它在可用空间下更适合,但每当我向ImageManipulator提供文件uri时,我都会收到一个错误“[未处理的承诺拒绝:错误:HostFunction中的异常:来自JS的错误调用:字段大小不同。]”。 这是

好的,我使用expo来管理我的react原生应用程序,在我的一项功能中,我允许用户选择要上传的文件,问题是用户可以选择任何类型的文件,因此我使用DocumentPicker,用户可以选择他想要上传的文件,问题是由于一些服务器容量问题,我需要使用ImageManipulator来操作图像,这样它在可用空间下更适合,但每当我向ImageManipulator提供文件uri时,我都会收到一个错误“[未处理的承诺拒绝:错误:HostFunction中的异常:来自JS的错误调用:字段大小不同。]”。 这是我的密码:

let result = await DocumentPicker.getDocumentAsync({
        type:"*/*" ,
    });
if (!result.cancelled) {
        const fileType=result.uri.substr(result.uri.lastIndexOf('.') + 1);

        if(fileType==="jpg" || fileType==="png" || fileType==="gif"){
             const manipResult = await ImageManipulator.manipulateAsync(
                     result.uri,
                     [{ resize: { width: manipulatedWidth, height: manipulatedHeight } }],
                     { compress: 0.7, format: ImageManipulator.SaveFormat.JPEG }
             );
        }
}

无论何时我使用ImagePicker而不是DocumentPicker,我都不会遇到这个错误,但在这种情况下,我确实需要使用DocumentPicker,以便用户可以选择要上载的文件