File Metadata Microservice (FCC Speedrun Project #12)

Abigail (agathalynn)
Chingu FCC Speedrun
2 min readMay 8, 2017

This one was… kind of anticlimactic.

The main difficulty I had was a conceptual one. The project involves uploading a file, getting the file size, and then returning the file size to the user. It took me a little while — and a bit of prompting — to figure out where I’m supposed to put the file that is being uploaded.

I was over-complicating things. I ended up just storing the file in a local variable within the request object. (And that’s even simpler than it sounds, because multer does it for you. By default.)

After I got that sorted, the project was pretty straightforward. I had to look up how to include a file upload in an HTML form:

And then I let multer handle the file upload:

Summoning multer
Using multer

There were a few places where I did trip up a little. It took me an error message or two to figure out that I needed to have the enctype='multipart/form-data' declaration on the form element. And to figure out that the name attribute on the input element and the string passed into .single() need to match.

Overall, though… I was not expecting this project to be so easy.

Huh.

(No live demo. Code HERE.)

--

--