Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Using perl to stream flash

by crashtest (Curate)
on Sep 23, 2006 at 02:34 UTC ( [id://574473]=note: print w/replies, xml ) Need Help??


in reply to Using perl to stream flash

Assuming this is about stealing bandwidth (no way to stop people from saving your flash to their computers), and you're not into the Apache options posted above, this would be a way to serve up a file using CGI:

use strict; use warnings; use CGI; my $flash_file = 'your_flash_file.swf'; open FLASH, '<', $flash_file or die $!; binmode FLASH; my $q = new CGI; print $q->header( -content-type => 'flash/swf' -content_Length => (stat FLASH)[7] ); my $buffer; while (read(FLASH, $buffer, 1024) > 0){ print $buffer; } close FLASH;
(add error-checking!)

You may need to do some research on the HTTP headers to send along with the data. I am just guessing at the Content-type, for instance.

Hope this helps.

Replies are listed 'Best First'.
Re^2: Using perl to stream flash
by Feltros (Acolyte) on Sep 25, 2006 at 00:44 UTC
    Yea thats the kind of solution I was looking for crashtest just wondered whether it was available to simply put content-type => flash/swf or whether it'd be more complex really... To reply to the others I can't stop hotlink access because i'm using the same website as they are, the access rules are a bit more complex than just that. And yes its about bandwidth, I don't care if someone steals my rubbishy 3mb music video (its literally the music with a pic of the album cover on it) its the fact everyone is just abusing my bandwidth and using my video on their own profiles and in all likelihood most people won't go to the effort of stealing mine and hosting it themselves.
      Apparently its Content-type: application/x-shockwave-flash from my research although i'm still at a miss as to the content length variable since I don't understand HTTP headers all that greatly - and reading the w3 info on them isn't that useful.

        So don't you have everything you need now? Just update the code I posted to point to your flash file, and change the content type from flash/swf to application/x-shockwave-flash.

        (stat FLASH)[7] is the code that determines and passes on the size of your flash file. You should be all set.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://574473]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-24 21:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found