Reputation: 995
If I have a file being served by a Media Server and therefore the URL has no file extension, how can I use JavaScript to find out what the extension actually is?
For example, lets say this is my url:
/MediaServer?MediaID=SomeRandomMediaIDWithoutExtension
I would like to use JavaScript to determine what type of media resides at that URL.
Upvotes: 0
Views: 163
Reputation: 1164
You could get the response header. For exemple :
$.ajax({
type: 'GET',
url:'/MediaServer?MediaID=SomeRandomMediaIDWithoutExtension',
success: function(data, textStatus, request){
alert(request.getResponseHeader('Content-Type'));
}
});
Or use Content-Disposition header. Wish returns possibly returns you filename. (Thanks yo @bhspencer)
As you said you'r looking for SRT / VTT
Those two files are formated differently so you could compare first lines of your file to determine his format.
Upvotes: 2