WebSpeed and Content-Range

Posted by tomasgreen on 02-Jun-2014 03:47

Hi!

I'm currently involved in a project where we have a number of video files stored in the database which is has to be accessible in a web app for iOS. The  problem with iOS and videos is that the server must serve the files with support for partial content. Normally I would simply store the file in the filesystem and serve it as static content with IIS, but the videos aren't public content and should only be read by authenticated users. This means that I need to stream the files through a script.

My question is if anyone has some kind of working example or even outline of how to achieve this with ABL/SpeedScript?

Thanks
/Tomas

Posted by mallen on 04-Jun-2014 04:42

Tomas,

If you have determined the range of bytes requested from the Range header sent by the client, you can use the copy-lob statement to extract those bytes from the file.

copy-lob from file {filename} starting at {pos} for {len} to object myMemptr.

You would also need to respond with a status of 206.

output-http-header("Status", "206 Partial Content").
output-http-header("Content-Length", "...").
output-http-header("Content-Range", "...").
output-http-header("Content-Type", "...").

{&OUT-LONG} myMemptr.

Regards

All Replies

Posted by mallen on 04-Jun-2014 04:42

Tomas,

If you have determined the range of bytes requested from the Range header sent by the client, you can use the copy-lob statement to extract those bytes from the file.

copy-lob from file {filename} starting at {pos} for {len} to object myMemptr.

You would also need to respond with a status of 206.

output-http-header("Status", "206 Partial Content").
output-http-header("Content-Length", "...").
output-http-header("Content-Range", "...").
output-http-header("Content-Type", "...").

{&OUT-LONG} myMemptr.

Regards

Posted by tomasgreen on 04-Jun-2014 05:37

You are a lifesaver mallen!

I've been trying to implement it the same way I did in PHP a while back but it turns out that's not an option and I had to simplify it according to your suggestion. The downside is a little overhead but thankfully the files are quite small so it shouldn't be a problem.

The one thing I had to change from your suggestion was how the content-type was set to the header. Apparently webspeed gets a little cranky when you use OUTPUT-HTTP-HEADER  instead of  OUTPUT-CONTENT-TYPE (probably because the header is somehow incomplete using only OUTPUT-HTTP-HEADER).

Anyway, thanks again!

This thread is closed