Node + react js increse upload file size in post request
Asked Answered
N

1

6

how can i increse upload file size in Node + react

i am successfully uploading csv file for 100k counts (14 mb)

but for 500K or 1000K . application crashes ..

i saw similar post , but that using express js to limit filesize

I am using fetch

fetch(url, {
        method: 'post',
        credentials: "same-origin",
        headers: {
            'user_token': sessionStorage.getItem('token'),
            'Accept': 'application/json',
            'Content-Type':'application/json',
        },          
        body: JSON.stringify({
        'uploadedData': this.state.uploadedData,
        }),
    })
    .then(response => response.json())
    .then(json => {

    })
}

i have tried to remove

'Accept': 'application/json',
'Content-Type':'application/json',

or use

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

But that doesnot work

I am using laravel server , I also increase upload file size limit on php.ini .. still not result

is there any way to increase file size ??

Neologize answered 13/12, 2019 at 8:13 Comment(5)
Can you share the crash data? Is the failure on the server side?Plated
error "aw snap , something went wrong" .. no detail comingNeologize
try adding this to the then block immediately after the fetch .. if (response.ok) { return response.json(); } else { throw new Error('Something went wrong'); }Plated
Does this answer your question? Node.js: how to limit the HTTP request size and upload file size?Bellbird
its using express js to set file limitNeologize
U
1

Try this in expressjs to increase limit of size

app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
Ungenerous answered 1/6, 2020 at 10:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.