I am trying to read the extension of a file which is coming from a server using web services in Angular 6.
I am able to read the extensions of the file like myFile.png
using filename.split('.').pop();
method and using filename.slice((filename.lastIndexOf(".") - 1 >>> 0) + 2);
method.
but my problem is the file link that is coming from the server is very long in length and it is a downloadable link so that from that link we can download the actual file.
Sample link format is as follows: http://myserver.data.com/data/service/auth/yt.content.ContentHttp/viewContent/myfile.png?u8&HttpOperationItem=yt.content.ApplicationData%3A342376&ofn=myfile.png&ContentHolder=yt.flow.forum.data%3A342370&forceDownload=true
In the above link, I want to read the extension of the file which is just before the (?)
operator. and the operator(?)
is coming only once in the link. so that I can identified that the extension of the file is placed just before the (?)
operator.
can anyone help to get the extension of the file using Angular 6.