Uploading file from google drive/cloud to my own server

In my application I have a functionality where user can upload his resume(of format .doc,.docx,.pdf). I’m using Ionic File Choosing plugin to choose the file and to upload I’m using Ionic File Transfer plugin. It is known that the file transfer plugin expects fileName filed in FileUploadOptions which will be the name of file to be uploaded with it’s extension. In my case say resume.pdf/doc/docx.

*For getting the file extension I’m passing the chosen file’s path to Ionic File Path plugin which will resolve it to it’s native path.

*The whole process is working absolutely fine when the file is chosen from mobile’s native file system.

*But when the file is chosen from drive/cloud application the Ionic File Path plugin throws error cannot be resolved to native path.

  • As I’m not able to resolve file path to it’s native path I’m not getting file’s extension.

*When I’m not aware of file’s extension it is not possible to upload the file to my server. (if I keep filename field empty in FileUploadOptions, by default name.jpg will be taken which may not be the type of file that I’m trying to upload).

  • Please suggest how can I get the extension of file that is chosen from drive or how can I upload a file without default filename field in FileUploadOptions.

I Found this answer to this finally. I have made an open gist of it. If anyone facing this issue kindly refer it.The link for the gist is as below.