Hi Mikael, On 5 May 2012 14:19, Mikeal Rogers <[email protected]> wrote: > Ultimately it's your call, but, waiting for it to finish streaming to disc > only increases the window of time a crash might prevent the file from > actually being persisted.
This is taken care of because if it crashes, the user doesn't get a 200, they will see an error and would be prompted to try again (depending on your how your application manages this). What connect-stream-s3 use-case takes care of is the case where you say to the user "File Uploaded" then your server disappears before you have managed to copy it elsewhere, back it up or (belatedly) copy it to S3. The user only gets a positive response once all files are persisted correctly in S3. :) > Also, are you passing the response info (status, headers, etc) from S3 to the > application response in express? It would be nice if this were > "transactional" and didn't return a 201 until it was actually persisted in S3. Yes and Yes. :) The middleware calls next() only after _every_ file has been properly persisted in S3 (with the help of Caolan's async module). The err and data response from every uploaded file is added to req.files as the 'S3' property, so req.files.file1.s3 (and req.files.file2.s3, etc) would have both an err and data object which are the one's returned from AwsSum. In the case of this operation (S3 PutObject) the data would have 'StatusCode(=200)', 'Headers' and an empty Body (since the S3 PutObject operation doesn't return a body). This may be inspected if required, but more useful is the req.files[file].s3ObjectName property which you'd probably use to put into your datastore against the user who uploaded it (again, dependent on your app). Hope that answers your questions. Cheers, Andy -- Andrew Chilton e: [email protected] w: http://www.appsattic.com/ -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
