From bab69d0fbba3f1a93463b377ce5f20161b5d2815 Mon Sep 17 00:00:00 2001 From: Harlan Barnes Date: Tue, 17 Sep 2019 15:14:44 -0400 Subject: [PATCH] Updating README.md with Link to uploadedFiles Maybe I'm just a dummy but I couldn't find any docs on the uploadedFiles array of objects so I am just adding a simple link to the code that describes that. Hope that's okay. Thanks for all you do. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f47c060..b1b0800 100644 --- a/README.md +++ b/README.md @@ -350,7 +350,7 @@ _When a multipart request is received..._ 2. In your application code, you call `req.file('foo')` to listen for file uploads sent as the "foo" parameter. This returns an "upstream"-- a stream of binary file streams; one for each file that was uploaded to the specified parameter ("foo") via an HTTP multipart file upload. At that point, if Skipper has already seen files come in as "foo", it will start uploading to the file adapter. This involves replaying the first buffered bytes its received of "foo" file uploads so far and "pumping" those streams so they start sending more bytes; i.e. relieving TCP backpressure. If Skipper has NOT already received any files as "foo", it will start listening for them. -3. When the request ends, or a significant (configurable) period of time has passed since a new file upload has shown up on "foo", the upstream is considered to be complete. If you're using `req.file('foo').upload(function(err,uploadedFiles){ ... })`, the callback will be triggered with `uploadedFiles` as an array of metadata objects describing the files that were uploaded (including the at-rest file descriptor.) If an error occured, the callback will be triggered with `err` instead. (Note that, if you're using the raw upstream directly, you can listen for the "finish" and "error" events to achieve the same effect.) +3. When the request ends, or a significant (configurable) period of time has passed since a new file upload has shown up on "foo", the upstream is considered to be complete. If you're using `req.file('foo').upload(function(err,uploadedFiles){ ... })`, the callback will be triggered with `uploadedFiles` as an array of [metadata objects](lib/private/Upstream/prototype.serializeFiles.js) describing the files that were uploaded (including the at-rest file descriptor.) If an error occured, the callback will be triggered with `err` instead. (Note that, if you're using the raw upstream directly, you can listen for the "finish" and "error" events to achieve the same effect.) 4. In general, when possible, you should put `req.file()` outside of asynchronous callbacks in your code. However this isn't always possible-- Skipper tolerates this case "holding on" to unrecognized file streams (e.g. "bar") for a configurable period of time. If you don't use `req.file("bar")` right away in your code, Skipper will "hold on" to any files received on that parameter ("bar"). However it __won't pump bytes from those files__ until you use `req.file('bar')` in your code. It does this without buffering to disk/memory by properly implementing Node's streams2 interface, which applies TCP backpressure and _actually slows down_, or even pauses, the upload. If you __never__ use `req.file('bar')` in your code, any unused pending file streams received on "bar" will be discarded when the request ends.