Streaming a binary file from riak via node.js to client

francisco treacy francisco.treacy at gmail.com
Sat May 21 07:00:32 EDT 2011


That should work, but i'll take a look at it. Which versions of
riak-js and Riak are you using?


2011/5/21 Max <nash12 at gmail.com>:
> After watching the presentation about how to use node.js with riak, I
> built some small application on node.js using the express framework.
>
> In riak files are stored via a PHP frontend but they should be served
> via a node.js backend. Anyway, connecting to riak via node.js is not
> that hard and sending the response is also rather easy. But it seems,
> somewhere the buffer I get via the client.get operation is truncated.
> I am using this code:
>
> app.get('/images/', function(req, res){
>    riakClient.get('images', 'some.jpg', function(err, image, meta) {
>        if (err) {
>            throw err;
>        }
>
>        res.send(image, {
>            'Content-Type': meta.contentType
>        });
>    });
> });
>
> To test if the image is served, but whenn I access the node.js url,
> the browser tells me that the image cannot be displayed as it contains
> errors. The filesize of the served image is too small compared to the
> original. If I access the url /images/some.jpg directly via rest
> interface on the command line, the correct image is returned.
>
> Has anyone experience in how to stream binary data from riak?
>
> Thanks in advance!
>
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>




More information about the riak-users mailing list