working code here. https://gist.github.com/3793279
# # blob : Object from MongoDB # # blob.body: Buffer # blob.size: length of buffer, substitute for blob.body.length # blob.type: MIME (Eg. audio/x-wav) # # req : Object from http # res : Object from http # _ : Object from underscore # if blob range = req.headers.range unless range res.writeHead 200, 'Content-Type': blob.type res.end blob.body else [ini, end] = _.map range.replace(/bytes=/, '').split('-'), (n) -> parseInt n, 10 total = blob.size chunk = end - ini + 1 console.log "#{ini}-#{end}/#{total} #{chunk}".cyan res.writeHead 206, 'Content-Type': blob.type 'Content-Length': chunk 'Content-Range': "bytes #{ini}-#{end}/#{total}" 'Accept-Ranges': 'bytes' res.end blob.body else res.writeHead 404 res.end() thx. 2012年9月11日火曜日 14時40分06秒 UTC+9 DToledo: > > So did you guys made it work? > Could you share the final code? I am trying something similar here. > Thx! > > On Tuesday, December 7, 2010 9:42:19 AM UTC-8, quantum wrote: >> >> Seems that you are incorrectly computing the content-length: >> >> var chunksize = (end-start)+1; >> >> If start is 0 and end is 1, in your case chunksize is 2, and it should >> be 1. >> That's why you're getting the 'loading' icon forever. >> >> Regards, >> Florin >> >> >> On Dec 7, 6:59 am, chrisharrington99 <chrisharringto...@gmail.com> >> wrote: >> > I was able to get the video to play no problems in firefox by setting >> > the "connection" header to "close". Chrome is still a pain in my ass, >> > but one step at a time... >> > >> > On Dec 6, 10:46 pm, chrisharrington99 <chrisharringto...@gmail.com> >> > wrote: >> > >> > >> > >> > >> > >> > >> > >> > > Deprecated or not, if I take the "binary" encoding out, the video >> > > doesn't play at all. >> > >> > > On Dec 6, 4:21 pm, mscdex <msc...@gmail.com> wrote: >> > >> > > > On Dec 6, 1:25 pm, chrisharrington99 <chrisharringto...@gmail.com> >> > > > wrote: >> > >> > > > > response.end(file.slice(start, end), "binary"); >> > >> > > > The "binary" encoding is deprecated. Assuming 'file' here is >> > > > instanceof Buffer, just passing in the slice should be enough >> > > > since .write()/.end() can handle buffers and buffers contain binary >> > > > data anyway. > > -- 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 nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en