chilts/awssum

Feature Request: Ability to stream blob responses

dominicbarnes opened this issue · 9 comments

I'd like to be able to act as a pseudo-proxy for S3 and pipe a readable stream of my S3.GetObject request directly to my end-user, particularly if it's something like an image where it's just blob data, especially if I don't plan on manipulating the object itself. Currently, I have to wait for the entire response to be loaded as a Buffer before I can write it to my server's response stream.

Yes, you're right. It's something I've wanted to add for a while.

There is a pull request I need to review and update so that it fits a little bit more nicely with the way AwsSum works.

I should get to it pretty soon.

Cheers,
Andy

FWIW, this is the only gripe we have with using awssum as our main tool for handling S3 uploads/downloads. Holding an entire body in-memory isn't really feasible as it slurps up the appserver's available memory pretty fast.
Having some kind of alias that allows you to upload a file (without knowing the filesize) would be very useful as well. I think this can be done by using the multipart APIs but that adds quite a bit of maintenance overhead on the implementer's side. It would be pretty awesome if awssum could abstract this away.

Hi Simon,

Yep, you're right (in part).

If you want to stream from disk for a PutObject you can already do this. Take a look at the following page:

There isn't a way to stream from S3 yet ... but I promise, I'm working on it. :)

Cheers,
Andy

What is the status of this, streaming downloads would be very nice?

Hi Guys,

I was working on it yesterday but I need to just do a slight re-arrangement to make it work (and understand a bit more about streams of course). I'll be able to have another go at it today. Fingers crossed it should be there in a day or two. :)

Cheers,
Andy

Hi Guys,

I've pushed what I think is an initial go at streaming downloads. Have a look at the example here:

Please let me know if anything looks weird. It'd be great if you could all test it since it'll definitely require some hard use cases.

Cheers,
Andy

Minor update to make sure we call the callback with an error if the status code is wrong.

Any plans to release it soon?

Hiya,

Yes, I'm hoping to release in the next week or so. I'm afraid it's all dependent on how much time I have though. :)

Cheers,
Andy