Document Picker Return Network Request Failed

Having problem with document picker, when i use expo document picker to upload image, it returns Network Request Failed, but if i use expo ImagePicker to upload image, it works well. my server doesnt have any problem coz i test it using postman and it goes well either documents or images. thanks. here’s my codes sample for uploading

                    let result = await DocPicker.getDocumentAsync();
                    //let result = await ImagePicker.launchImageLibraryAsync();

                    let localUri = result.uri;
                    let filename = localUri.split('/').pop();
                    let match = /\.(\w+)$/.exec(filename);
                    let type = match ? `image/${match[1]}` : `image`;
                    let obj = {
                                uri: localUri,
                                name: filename,
                                type: type

                    let formData = new FormData();
                    formData.append("ClientID", "some clientid");
                    formData.append("SLT_CODE", "1");
                    formData.append("OL_TEMP_APP_NO", "client application number");
                    formData.append("Files[]", obj);

                    fetch("server url", {
                        method: 'POST',
                        headers: {
                          'Accept': 'application/json',
                          'Content-Type': 'multipart/form-data',
                          'KEY': "api key"
                        body: formData
                    }).then((response) => response.json())
                    .then((json) => { console.log(json); }
                    ).catch((error) => { console.log(error) });


Hey @dylanvillaruel, would you be able to put this into a public repo that we can clone and run locally? Also, can you let me know what platform(s) this occurs on and does this occur when running on a physical device, simulator, both?


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.