Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

Playing music file and hide file's path

Hi,
How can I users listen to a music file but not letting them know the path to the music file?
Can this be done in cgi? Thanks very much.
0
qazs
Asked:
qazs
  • 6
  • 6
1 Solution
 
ahoffmannCommented:
write a CGI script which reads the music file and writes it as response with a proper HTTP header
best if the music file is located outside DocumentRoot of your web server
0
 
qazsAuthor Commented:
Thanks. But how do I read a music file? I only know how to read an image file.
Can you direct me to some online articles or tutorials regarding this? I can't seem to find any.
0
 
ahoffmannCommented:
you read a music file simply as binary data
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
qazsAuthor Commented:
Is it something like this:
print $query->header(-type=>'audio/x-mp3');
#print $query->header;
$dir = '/music_folder/';
$ext = 'mp3';
open (FILE, "$dir$music_file.$ext") or die "Can't open music file";

binmode FILE;
while(read(FILE, my $buf, 512)){
      print $buf;
}
0
 
ahoffmannCommented:
yes
finally add:
exit(0);
0
 
qazsAuthor Commented:
Hi,
another thing.
I'm not sure about what you mean by:
"best if the music file is located outside DocumentRoot of your web server".

Can you explain what you meant?
Will others still be able to find the exact path of the music file if I put it in a sub directory, but using cgi to play it?
0
 
ahoffmannCommented:
assuming your static html files are served from /path/to/docs then this is the DocumentRoot.
You have your CGIs then served from for example /path/to/cgi-bin (sometimes known as ProgramRoot or script directory), which cannot contain static html files.
Both directories are configured in the web server, and the client access this then using an URL like:
  http://your.tld/static.html
which will result in delivering /path/to/docs/statisc.html. Same for cgi-bin.

Now place your data files in for example /path/to/data, which is initially unknown to the web server, but you CGI can access it. This way it cannot be access through URL, even if the lient knows the full path. Some kind of a second line of defence.
0
 
qazsAuthor Commented:
Ok... another problem here.
The script works alright with Windows Media Player, but plays awkwardly in Quicktime.
In Quicktime, it just plays a small portion of it. It's like loading a small part of the song and playing it.
Any idea how to fix it?
0
 
ahoffmannCommented:
sounds like there is something different with the HTTP header, I guess a quicktime problem
0
 
qazsAuthor Commented:
hi,
I've a very serious problem here.
I'm able to hide the music file's path and let users hear the song in Internet Explorer. It just opens up the Windows Player and plays the music from the source, eg:
http://url.com/cgi-bin/music.cgi?file=xyz

Ok, but in Mozilla, it prompts the user to open the file, and then download a copy of the file in the temp folder!

Is there a way to prevent Mozilla Firefox from doing this?
0
 
ahoffmannCommented:
> Is there a way to prevent Mozilla Firefox from doing this?
either Firfox needs to add the proper MIME type, or you need to sedn a MIME type which is known by default by Firefox
0
 
qazsAuthor Commented:
Thanks. I found a solution by using m3u file.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now