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) });
console.log(formData);