Link to home
Start Free TrialLog in
Avatar of keneso
keneso

asked on

protection from download

Hi,

how can I protect an mp3 file, that is streamed, to be downloaded from the website?

Thank you.
Avatar of rdivilbiss
rdivilbiss
Flag of United States of America image

Well if it is streamed than anyone with FLV Player or something similar can intercept it and save it in a local file.

If you don't want people directly downloading the file, then you must use some server side script to send content headers with the correct mime type to the browser, open the file as binary and stream the binary to the browser.

I have examples of doing this for image files, for mp3 you just use a different content disposition header.

What server side scripting language can you use?
Didn't notice your user ID. You have ASP, so...

<%
mp3 = "/path/to/file/somefile.mp3"

' no browser caching of this page !! to be used on all pages

Response.Expires=-1
Response.ExpiresAbsolute = Now() - 1

' do not allow proxy servers to cache this page !! to be used on all pages
Response.CacheControl="private"
Response.CacheControl="no-cache"
Response.CacheControl="no-store"

Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
 
'Open a image file
objStream.Type = 1 ' adTypeBinary
objStream.Open
objStream.LoadFromFile Server.MapPath(mp3)
 
'Output the contents of the stream object
Response.ContentType = "audio/mpeg"
Response.BinaryWrite objStream.Read

objStream.Close
%>"

http://www.rodsdot.com/ee/stream_MP3_with_ASP.asp
Avatar of keneso
keneso

ASKER

Hey, I was going to post on another forum as well, but I guess I can just do it here. ;)

Supp. Microsoft .NET Framework                      
Supp. Visual Studio .NET                   
PHP 4 o superiore                   
PERL 5.6.1 o superiore                   
ASP 3.0                   
ASP .NET 2.0                   
ADO .NET                   
XML 4                   
WAP                   
GDlib                   
Imagemagick

>> Well if it is streamed than anyone with FLV Player or something similar can intercept it and save it in a local file

Or can even see the path in the page source.
Avatar of keneso

ASKER

Thanks.
You are too fast for me. ;)

I am afraid I wasn't very detailed in the question.

Do I just put that on the page, and it'll keep playing as a background?
Cause I have put an mp3 streamer that users should click on to start the streaming.
I don't know if it will play as background, as that depends on the browser and the plugins available for the persons browser.

If you emdeb an object tag, such as windows media player, then instead of giving it the filename.mp3 parameter, just give it the name of the streaming asp page.

The example page above has a link to the streamer, but in my IE7 it loads my external player, because I've removed all media plugins from IE7.
>>Or can even see the path in the page source.

Not with my method...they will not see the path to the file.  Just to the streaming page.

Normally I would pass a parameter (integer not file name) then do a select case on the parameter to select the source file to stream.  If no parameter, or a wrong parameter, then I redirect to a 404 page.

There may be other mime types you can use which will affect how it plays.

In FF it opens inside my browser.
Avatar of keneso

ASKER

Ok, I am going to try it right now.
Will get back in short time.
Avatar of keneso

ASKER

>>Not with my method...they will not see the path to the file.  Just to the streaming page.

I meant as I have set it up now, I am sure you know what you are talking about.
Re visit http://www.rodsdot.com/ee/stream_MP3_with_ASP.asp

You can't find the path to the mp3 file and it streams in the background.
Avatar of keneso

ASKER

Hmmm ... as usual I think I am missing something here ...

Let me recap what I have done so you can see what I am missing, or doing wrong.

This is the site
http://www.jamsette.com

Before posting this I had tried a limited access page path, which would have shown the path nontheless, and when tried the direct link to the file, on one box it would open the save to dialogue, and on another box it would open a browser page with the quicktime player (like your latter link), and wouldn't give access to download.

I created a page, deleting the player, and putting the code
<object width="300" height="42">
[ ... cut ...]  
</embed>
</object>
in the upper side of your latter link, then I copy/pasted the asp part and named it streamMP3.asp
Hence I have two files the html with the <object> and the asp file.
I uploaded and it won't work.
ASKER CERTIFIED SOLUTION
Avatar of rdivilbiss
rdivilbiss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of keneso

ASKER

Thanks.
I created the io22.html file
and the io2.asp file
http://www.jamsette.com/io22.html

But on one machine IE shows the quicktime Q with a '?', and FF a blank page with "done" on status bar.

On another box IE displays the wmp (old version) but nothing playing
and FF same blank page

>>mp3 = "/images/123.mp3" '<--- make sure to change this to a valid mp3 file

That should be the path to the file right?
Like I have
mp3 = "assests/sound/valms1_promo.mp3"

I also tried
mp3 = "/assests/sound/valms1_promo.mp3"
Do you have some restriction of permissions in the assets or sounds folders?

Try moving one mp3 file to the same place as the test pages.

Do my sample pages play for you?
mrs. fatcontroller regularly 'downloads' streamed internet media (radio, from the bbc, i'm ashamed to reveal), by playing it in the necessary player and recording it using the requisite real time sound recorder.

I'd bet more than 1c that whatever I can hear/receive on my computer is recordable.
We already established that if you can hear it you can capture it, but that doesn't meen he has to make it easy to link to the files.

Say, for example people linking directly to the file and stealing your bandwidth.  That can be a far worse problem, than allowing a person to hear the file and possibly capture it.
Avatar of keneso

ASKER

>>We already established [... cut ...] possibly capture it.

Indeed.

>>Do you have some restriction of permissions in the assets or sounds folders?

No.

>>Try moving one mp3 file to the same place as the test pages.

Already done that too, but no luck

>>Do my sample pages play for you?

Yes, and that's the most intriguing thing, 'cause I copy/pasted your code, and just changed this
mp3 = "/images/123.mp3" '<--- make sure to change this to a valid mp3 file
to
mp3 = "valms1_promo.mp3"
mp3 = "assets/sound/valms1_promo.mp3"

Of course with the mp3 in both folders, the one with the asp, and html files, and the sound folder.
Avatar of keneso

ASKER

Tonight I had this idea:

If you think the idea could have a possibility I'll PAQ this, since your solution is working, and I just have to find what's causing the issue, and open a new one.

The flash player I have on the site references the mp3 file

==== CODE ====
<script type="text/javascript">
      var FO = { movie:"assets/player/mp3player.swf",width:"180",height:"200",majorversion:"7",build:"0",bgcolor:"#FFFFFF",
            flashvars:"file=assets/sound/valms1_promo.mp3&image=assets/img/cd/cov.jpg" };
      UFO.create(FO,"player1");
</script>
==== /CODE ====

Would it be possible to reference an asp page containing the link to the mp3 file?

I started playing with that yesterday, but my wife made me stop and do real world work :(

I will try time permitting.
Avatar of keneso

ASKER

>>but my wife made me stop and do real world work :(

Did you tell her it's for me? ;)

Ok, I am PAQing this, thank you again.
Points 250 > 500 ('cause you know you deserve it ;)
Avatar of keneso

ASKER

I'll open the other question in few days, and will be very happy to see you there.
Avatar of keneso

ASKER

Forgot to thank you.

Thanks a lot.
LOL - I may not answer any more of yours <smile>