Free Email Course on Node.js File Uploads

decoration
thumbnail

1. Understand How Browser Submits Form

Do you know what the browser does when you submit a form? More specifically, what happens if the form contains a file upload element? Check out the HTTP request that gets created in that case. You'll be surprised at what's included... and what's not!

decoration
thumbnail

2. Upload File Contents With Multipart Form Data Encoding

If the browser doesn't include file contents by default, how can you make it send them? You don't do much with only the filename, you also need the contents for your app to be useful. The cure is to add one extra attribute to the form. You'll also get to meet multipart/form-data HTTP request, something that is at the heart of file uploads.

decoration
thumbnail

3. Avoid Storing Intermediate Files

Now you've got the file contents on your Node server. Then, what should you do with the data? What options do you have? Which best suits your case? Learn the different ways to handle files and their pros and cons.

decoration
thumbnail

4. Stream Uploaded File to File Server

Now that you know your options for what to do with the files, there's one important point about how you move the file data around. Ideally, you'd write code that keeps the production server up and running even under heavy loads. Luckily, there's a way to avoid wasting resources and not hold to any piece of data longer than necessary.