Jump to content

JS/Express Send a very big string to an express server

Playlogo

What is the best way to send a very big String to a nodeJs express server?
I have a Webpage with Codemirror which is able to load files from a express server and load them into Codemirror.
But what method is the best to send "the file"(actually it's a string,can be realy big) back to the express api ?

 

!! RGB !!

Link to comment
Share on other sites

Link to post
Share on other sites

Use, standard POST. If it a really big file that is hundreds/thousands of mb then file upload.

Link to comment
Share on other sites

Link to post
Share on other sites

I don't know codemirror so maybe this isn't relevant, but I suspect that it may be. The most common issue when trying to send a large amount of data is on the receiving end. Servers like Nginx (which often act as a proxy to Node) have a max file size limit. They also have a max number of inputs, max input size, etc... Even when Nginx isn't acting as a proxy Node / Express (Python, Go, Ruby, Java all) have similar limits. As you're on a 3rd party server I highly doubt you'll be able to adjust either/any of those configurable options. On the client side the most common issue when sending a POST request is forgetting to set the content type header to an appropriate setting which in your case is likely, multipart/form-data - You can read more about that here. eg. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type or here https://stackoverflow.com/questions/8659808/how-does-http-file-upload-work 

The reason I mention it is because the server side config concerning the max file size upload is (almost always) much larger than the form data size limits. So as has been mentioned above you'll want to send that blob as a file if you can. If that doesn't work you can always get a Raspberry Pi and build your own under-desktop-server. Digital Ocean has Linux VPS servers for US $5/mo.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×