WebFund 2016W Lecture 17
Video
The video from the lecture given on March 15, 2016 is now available.
Notes
Instructor comments
In class I had trouble with downloading the file. Everything worked except that the downloaded file became [Object object].
The problematic line was this, in downloadFile()
response = allFiles[i].buffer.toString('utf8');
This line should work because when we stored the file in uploadText() it did. But in between (perhaps when stored as a session property) it was changed.
Before, we had:
{ '0': 123, '1': 10, '2': 32, '3': 32, ... }
But now this got changed into:
{ type: 'Buffer', data: [ 123, 10, 32, 32, ... ] }
The former is of type Buffer (as reported by Buffer.isBuffer()), the latter is not.
While this is strange behavior, the fix is easy:
response = Buffer(allFiles[i].buffer.data).toString('utf8');
This is definitely a bug in node or express. If anyone wants to try isolating this bug and reporting it, let me know!