As per the requirement ,the client is provide with an exe-(which contains the url of file to be downloaded) If we use the google api, we need to provide additional references along with the exe. It is not allowed by the client.
I used the webclient to download the file, but its downloading the file with doc type as HTML. My requirement is to download the file form google drive without using google API. Is there any way to do that?
I have tried the code as below
WebClient wb = new WebClient();
wb.DownloadFile("https://drive.google.com/file/d/0BzpAdEg-KyDjNVVSb0FBOWQ4V0k/view?usp=sharing", @"C:\TFS\test\test.pdf");
Result as shown below
Drag files into Google Drive On your computer, go to drive.google.com. Open or create a folder. To upload files and folders, drag them into the Google Drive folder.
On your iOS or Android devices, open the Google Drive app. Tap Upload. Find and tap the files you want to upload. View uploaded files in My Drive until you move them to another folder.
This should help you.
Below is the standard sharing url for google drive.
https://drive.google.com/file/d/FILE_ID/edit?usp=sharing
the format you need to use for direct downloads is:
https://drive.google.com/uc?export=download&id=FILE_ID
this will link directly to the file instead of to the drive view in your current example.
so, for example, if your sharing url is https://drive.google.com/file/d/ABCDEFG1234567/edit?usp=sharing
then your direct download url is https://drive.google.com/uc?export=download&id=ABCDEFG1234567
Note, this is only for files you have uploaded yourself that were not created in drive itself (ie, doc, presentation, spreadsheet) using the google docs. to do that the format changes (will update answer if you need it)
Edit:
It is worth noting that if the files location changes then the url and direct download link will change too, meaning you will need to update it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With