joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.84k stars 784 forks source link

413 Request Entity Too Large #584

Open Anujmoglix opened 4 years ago

Anujmoglix commented 4 years ago

Getting issue

"

413 Request Entity Too Large

413 Request Entity Too Large


nginx/1.10.3 (Ubuntu)

"

My code is

RNFetchBlob.fetch('POST', 'http://xyz.com//addFile', {
    'token': AppStorage.getToken(),
    'userid': AppStorage.getUserId(),
    'Content-Type' : 'multipart/form-data',
  }, [
    // element with property `filename` will be transformed into `file` in form data
   // { name : 'avatar', filename : 'avatar.png', data: binaryDataInBase64},
    // custom content type
    //{ name : 'avatar-png', filename : 'avatar-png.png', type:'image/png', data: binaryDataInBase64},
    // part file from storage
    { name : 'file', filename : 'avatar-foo.jpeg', type:'image/jpeg', data: RNFetchBlob.wrap(photo.path)},
    // elements without property `filename` will be sent as plain text
    { name : 'counterUserId', data : this.state.chatUser.userId},
    // { name : 'info', data : JSON.stringify({
    //   mail : 'example@example.com',
    //   tel : '12345678'
    // })},
  ]).then((resp) => {
kristijantomic commented 4 years ago

It is not problem with your client code but Nginx has default set to 1MB upload. You should increase it. Check this out: https://www.tecmint.com/limit-file-upload-size-in-nginx/