How to download document on google drive

This might help you. You can retrieve any file using a url and save it to your local environment. You can also use it to determine the mine type based on the comment, not just the extension.