DocumentPicker: limited document size while submit

  1. SDK Version: 42.0.1
  2. Platforms(Android/iOS/web/all): android

this is my code
const _pickDocument = async() => {

    let result = await DocumentPicker.getDocumentAsync({copyToCacheDirectory:false,type:'application/pdf'})

    .then(response=>{

        if (response.type == 'success') {          

            let { name, size, uri, tmp_name, type } = response;

            let nameParts = name.split('.');

            let fileType = nameParts[nameParts.length - 1];

            var fileToUpload = {

              name: name,

              type: mime.getType(fileType),

              size: size,

            //   uri: Platform.OS === 'ios' ? uri : "file://"+uri,

              uri: Platform.OS === 'ios' ? uri : uri,

            //   uri:("file:///"+uri.split("file:/").join("")),

            };

            console.log(fileToUpload, '...............file')

            setDoc(fileToUpload);

        }

    })

    .catch(error=>{

        console.log(error)

        throw error

    })

}

const submitDoc= async()=>{

    const url = "your url";

    if(kategoriValue==null){

        alert("bagian * wajib diisi");

        return;

    }

    setIsLoading(true)

    axios.post(url, docFormData,{

        headers:{

            Accept: 'application/json',

            'Content-Type':'multipart/form-data'

        }

    }).then(response=>{

        console.log(response)

        setIsLoading(false)

        alert(response.data)

    }).catch(error=>{

        console.log(error)

    })

}

I want to ask if there is a limit in sending a document. Why do the file failed to send to url if the file size is more than 1.8 MB? Is there any way to increase the size limit? Thank you.

Hey @egbertgan, this could be an OS-level restriction but I’m not entirely sure. Have you tried looking to the apple docs? Also, can you share exactly what the logs spit out when trying to select a larger doc?

this is for android and this is the object result

Object {
“name”: “PA824_User_Manual.pdf”, “size”: 2659219,
“type”: “application/pdf”, “uri”: “file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540egbertgan%252Fmodern-trade/DocumentPicker/e04a8b31-91b1-4b22-92c4-276bdd219a1f.pdf”, }

while this is the result after post

“responseURL”: “your php url”, “data”: “Ada Kesalahan, file PDF corrupt”, “status”: 200, “timeout”: 0, “upload”: XMLHttpRequestEventTarget {}, “withCredentials”: true,

so basically, even though it is a success. My pdf file size become 0 byte and what makes it weird is that if the pdf file less than 1.8MB, the file exist.

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