Oracle Magazine, July/August 2019
ORACLE MAGAZINE JULY AUGUST 2019 64 Database Developer OPEN SOURCE res status 201 json fileId fileId catch err console log err res header Connection close res status 500 json error Oops something broke req connection destroy catch err next err module exports post post The controller logic above starts by declaring and initializing some variables Note that contentBuffer is an array in which data will be buffered during a file upload Also the code expects the files name and content type to be passed in via HTTP headers because the HTTP body is reserved for the file content An event listener is added to the requests data event This event will be triggered one or more times as data is transferred from the client to the server The callback function takes the data passed in a Buffer by default and pushes it into the contentBuffer array The rest of the logic in the function is used to track the number of bytes in the buffer If the maximum file size maxFileSize of 50 MB is exceeded
You must have JavaScript enabled to view digital editions.